Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recalculate python markers on dependency more often #284

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion src/poetry/core/packages/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def marker(self, marker: Union[str, "BaseMarker"]) -> None:
for _, extra in or_:
self.in_extras.append(extra)

# Recalculate python versions.
self._python_versions = "*"
if "python_version" in markers:
ors = []
for or_ in markers["python_version"]:
Expand Down Expand Up @@ -213,7 +215,8 @@ def marker(self, marker: Union[str, "BaseMarker"]) -> None:
ors.append(" ".join(ands))

self._python_versions = " || ".join(ors)
self._python_constraint = parse_constraint(self._python_versions)

self._python_constraint = parse_constraint(self._python_versions)

@property
def transitive_marker(self) -> "BaseMarker":
Expand Down
10 changes: 10 additions & 0 deletions tests/packages/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,13 @@ def test_dependency_markers_are_the_same_as_markers():
marker = parse_marker('extra=="bar"')

assert dependency.marker == marker


def test_marker_properly_unsets_python_constraint():
dependency = Dependency("foo", "^1.2.3")

dependency.marker = 'python_version >= "3.6"'
assert str(dependency.python_constraint) == ">=3.6"

dependency.marker = "*"
assert str(dependency.python_constraint) == "*"