Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/python_inspector/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ def is_valid_version(
"""
Return True if the parsed_version is valid for the given identifier.
"""
if (
any(parsed_version not in r.specifier for r in requirements[identifier])
or parsed_version in bad_versions
):
if parsed_version in bad_versions:
Comment thread
TG1999 marked this conversation as resolved.
return False
if any(parsed_version not in r.specifier for r in requirements[identifier]):
if all(not r.specifier for r in requirements[identifier]):
return True
return False
return True

Expand Down Expand Up @@ -453,16 +454,22 @@ def get_candidates(
"""
Generate candidates for the given identifier. Overridden.
"""
valid_versions = []
for version in all_versions:
parsed_version = parse_version(version)
if not is_valid_version(
if is_valid_version(
parsed_version=parsed_version,
requirements=requirements,
identifier=identifier,
bad_versions=bad_versions,
):
continue
yield Candidate(name=name, version=parsed_version, extras=extras)
valid_versions.append(parsed_version)
if all(version.is_prerelease for version in valid_versions):
Comment thread
TG1999 marked this conversation as resolved.
Outdated
pass
else:
valid_versions = [version for version in valid_versions if not version.is_prerelease]
for version in valid_versions:
yield Candidate(name=name, version=version, extras=extras)

def _iter_matches(
self,
Expand Down Expand Up @@ -504,7 +511,11 @@ def find_matches(

def is_satisfied_by(self, requirement: Requirement, candidate: Candidate) -> bool:
"""Whether the given requirement can be satisfied by a candidate. Overridden."""
return candidate.version in requirement.specifier
if candidate.version in requirement.specifier:
return True
elif not requirement.specifier:
return True
return False

def _iter_dependencies(self, candidate: Candidate) -> Generator[Requirement, None, None]:
"""
Expand Down
2,015 changes: 2,015 additions & 0 deletions tests/data/azure-devops.req-expected.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/data/azure-devops.req.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
azure-devops
azure-storage-blob
click
18 changes: 18 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ def test_cli_with_environment_marker_and_complex_ranges():
)


@pytest.mark.online
def test_cli_with_azure_devops():
requirements_file = test_env.get_test_loc("azure-devops.req.txt")
expected_file = test_env.get_test_loc("azure-devops.req-expected.json", must_exist=False)
extra_options = [
"--operating-system",
"linux",
"--python-version",
"38",
Comment thread
TG1999 marked this conversation as resolved.
]
check_requirements_resolution(
requirements_file=requirements_file,
expected_file=expected_file,
extra_options=extra_options,
regen=REGEN_TEST_FIXTURES,
)


@pytest.mark.online
def test_cli_with_multiple_index_url_and_tilde_req_with_max_rounds():
expected_file = test_env.get_test_loc("tilde_req-expected.json", must_exist=False)
Expand Down