Repository navigation
fix: normalize nested extra marker values - #1246
Merged
henryiii merged 2 commits intoJun 16, 2026
Merged
Conversation
henryiii
reviewed
Jun 12, 2026
notatallshaw
approved these changes
Jun 13, 2026
notatallshaw
left a comment
Member
There was a problem hiding this comment.
The isinstance(rhs, Value) / isinstance(lhs, Value) guards also fix a separate bug: a variable-vs-variable atom no longer gets rewritten into a string literal:
str(Marker("extra == os_name")) # main: extra == "os-name" (os_name turned into a literal!)
# here: extra == os_name (correct)
Add a test for this.
Add a regression test for the case where extra is compared to another environment variable rather than a string literal. The isinstance guards ensure such atoms are left untouched instead of being rewritten into a normalized string literal. Assisted-by: ClaudeCode:claude-opus-4.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes one of the
markers.pyissues reported in #1239._normalize_extra_values()delegates each top-level marker item to_normalize_extras(), but_normalize_extras()only handled tuples. Parenthesized marker groups are represented as nested lists, so literalextracomparisons inside parentheses skipped PEP 685 normalization.This makes
_normalize_extras()recurse through nested marker lists and keeps the literal-only guards aroundextranormalization so variable operands are not rewritten by this scoped fix.Tests:
uv run pytest tests/test_markers.py -quv run ruff check src/packaging/markers.py tests/test_markers.pyuv run ruff format --check src/packaging/markers.py tests/test_markers.pyPre-submit review: Codex approved the final scoped diff after earlier review feedback identified that broader variable-variable marker semantics should be left for a separate, spec-backed patch.