Skip to content

Commit

Permalink
Fix some lints and add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
apljungquist committed Nov 27, 2022
1 parent 71127ab commit 943fffc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shlex
import sys
import tempfile
from typing import IO, Any, BinaryIO, List, Optional, Set, Tuple, Union, cast
from typing import IO, Any, BinaryIO, cast

import click
import pep517
Expand Down
20 changes: 17 additions & 3 deletions tests/test_cli_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,52 +2497,65 @@ def test_all_extras_fail_with_extra(fake_dists, runner, make_module, fname, cont


def _actual_deps(keys: Iterable[str], text: str) -> dict[str, str | None]:
result = {k: None for k in keys}
# TODO: Consider making it possible to compare the actual- and expected-deps
# without adding a bunch of None in the actual deps.
result: dict[str, str | None] = {k: None for k in keys}

for line in text.splitlines():
if line.startswith("#"):
continue
try:
k, v = line.split("==")
except ValueError as e:
except ValueError:
continue
result[k] = v

print(result)
return result


class Version:
def __init__(self, expected: str | None) -> None:
self._pat = expected

def __eq__(self, other: str | None) -> bool:
def __eq__(self, other: object) -> bool:
if None in {self._pat, other}:
return self._pat is other

if not isinstance(other, str):
return False

return fnmatch.fnmatch(other, self._pat)

def __repr__(self) -> str:
return f"<{self.__class__.__name__}@{id(self)}(_pat={self._pat!r})>"


# TODO: Consider isolating test results from PyPi
METADATA_TEST_CASE_BUILD_DEPS = {
"flit": {
"flit-core": Version("*"),
"poetry-core": Version(None),
"setuptools": Version(None),
"wheel": Version(None),
},
"poetry": {
"flit-core": Version(None),
"poetry-core": Version("*"),
"setuptools": Version(None),
"wheel": Version(None),
},
"setup.cfg": {
"flit-core": Version(None),
"poetry-core": Version(None),
"setuptools": Version("*"),
"wheel": Version(None),
},
"setup.py": {
"flit-core": Version(None),
"poetry-core": Version(None),
"setuptools": Version("*"),
"wheel": Version("*"),
},
}

Expand Down Expand Up @@ -2586,6 +2599,7 @@ def test_build_system_requires(
expected_deps.update(build_deps)

actual_deps = _actual_deps(expected_deps.keys(), out.stderr)
# Compare as dicts to see all differences in pytest output
assert actual_deps == expected_deps


Expand Down

0 comments on commit 943fffc

Please sign in to comment.