Skip to content

fix: Preserve nested tuple parentheses - #487

Merged
pawamoy merged 2 commits into
mkdocstrings:mainfrom
lprnmns:fix/nested-tuple-contexts
Sep 1, 2026
Merged

fix: Preserve nested tuple parentheses#487
pawamoy merged 2 commits into
mkdocstrings:mainfrom
lprnmns:fix/nested-tuple-contexts

Conversation

@lprnmns

@lprnmns lprnmns commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

For reviewers

  • I did not use AI
  • I used AI and thoroughly reviewed every code/docs change

Description of the change

Keep tuple-context flags local to the immediate AST node. Previously, a subscript or comprehension-target flag could flow through a nested list, call, or comprehension and remove tuple parentheses below it. This changed the rendered AST in cases such as o[f((x, y))] and could produce invalid Python for a tuple-valued comprehension nested in a subscript.

Four round-trip regressions cover nested containers, calls, comprehensions, and destructuring targets.

Validation:

  • Focused regression: 4 passed
  • PYTHON_VERSIONS='' ./scripts/make format check test — passed
  • Additional deterministic expression matrix — 861 valid cases, 0 failures

Relevant resources

@lprnmns
lprnmns marked this pull request as ready for review September 1, 2026 05:54

@pawamoy pawamoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Found a simplification 🙂 Let me know what you think.

@lprnmns

lprnmns commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

The simplification looks good to me and keeps the context behavior covered. Thanks for the fixup.

@pawamoy
pawamoy merged commit e095a7c into mkdocstrings:main Sep 1, 2026
34 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.

2 participants