Skip to content

fix(markers): keep parentheses of a nested group when serializing - #1316

Merged
notatallshaw merged 1 commit into
pypa:mainfrom
notatallshaw:markers-nested-paren-serialization
Jul 6, 2026
Merged

notatallshaw merged 1 commit into
pypa:mainfrom
notatallshaw:markers-nested-paren-serialization

Conversation

@notatallshaw

@notatallshaw notatallshaw commented Jul 6, 2026 •

Copy link
Copy Markdown
Member

Keeps the parentheses of a nested and/or group so str(Marker(...)) round-trips.

Fixes #1315

str(Marker(...)) dropped the parentheses of a parenthesized group
nested inside a larger and/or expression, because _format_marker
unwrapped the redundant [[...]] wrapper with first reset to True.
The string then reparsed with different precedence and could
evaluate to the opposite result. Thread first through the unwrap so
a nested group keeps the one pair of parentheses it needs.

@henryiii henryiii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

@notatallshaw
notatallshaw merged commit 0a85b41 into pypa:main Jul 6, 2026
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

str(Marker(...)) drops parentheses of a nested group and changes evaluation

2 participants