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

Fix: failure to handle extra if env is not empty but does noot have extra #1

Merged
merged 2 commits into from
Dec 15, 2023
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
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ dev = [
"pytest>=7.4.3",
]

[tool.pdm.scripts]
test = "pytest"

[tool.pytest.ini_options]
addopts = "-ra"
testpaths = [
"src/",
"tests/",
]

[tool.pyright]
venvPath = "."
venv = ".venv"
Expand Down
2 changes: 1 addition & 1 deletion src/dep_logic/markers/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def only(self, *marker_names: str) -> BaseMarker:

def evaluate(self, environment: dict[str, str] | None = None) -> bool:
pkg_marker = _Marker(str(self))
if self.name != "extra" or not environment:
if self.name != "extra" or not environment or "extra" not in environment:
return pkg_marker.evaluate(environment)
extras = [extra] if isinstance(extra := environment["extra"], str) else extra
assert isinstance(self, MarkerExpression)
Expand Down
2 changes: 2 additions & 0 deletions tests/marker/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def test_evaluates(
# single extra
("extra != 'security'", {"extra": "quux"}, True),
("extra != 'security'", {"extra": "security"}, False),
("extra != 'security'", {}, True),
("extra != 'security'", {"platform_machine": "x86_64"}, True),
# normalization
("extra == 'Security.1'", {"extra": "security-1"}, True),
("extra == 'a'", {}, False),
Expand Down