Skip to content

fix(pytree): initialize bracket_depth in Leaf __init__ - #5267

Open
amir-rezaei wants to merge 1 commit into
psf:mainfrom
amir-rezaei:fix/leaf-bracket-depth-initialization
Open

fix(pytree): initialize bracket_depth in Leaf __init__#5267
amir-rezaei wants to merge 1 commit into
psf:mainfrom
amir-rezaei:fix/leaf-bracket-depth-initialization

Conversation

@amir-rezaei

@amir-rezaei amir-rezaei commented Jul 28, 2026

Copy link
Copy Markdown

Description

Fixes #5214, closes #5221, closes #5215
This PR resolves issue #5214 by initializing bracket_depth: int = 0 in Leaf.__init__() and as a class attribute in src/blib2to3/pytree.py.

Details

  • Prevents AttributeError: 'Leaf' object has no attribute 'bracket_depth' when processing newly constructed Leaf instances during line formatting.

@cobaltt7

Copy link
Copy Markdown
Collaborator

@amir-rezaei This PR needs a new test case added to tests/data/cases. The crashing code is provided in the original issue.
Please also add a changelog entry detailing the user-facing change.

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.

Leaf.bracket_depth not initialized

3 participants