Skip to content

Fix autofix checkpoint placement in except clauses#442

Merged
Zac-HD merged 2 commits intopython-trio:mainfrom
Zac-HD:claude/fix-checkpoint-placement-Xu0e1
Apr 20, 2026
Merged

Fix autofix checkpoint placement in except clauses#442
Zac-HD merged 2 commits intopython-trio:mainfrom
Zac-HD:claude/fix-checkpoint-placement-Xu0e1

Conversation

@Zac-HD
Copy link
Copy Markdown
Member

@Zac-HD Zac-HD commented Apr 20, 2026

The autofix for missing checkpoints (ASYNC910/ASYNC911) used to insert await ...checkpoint() right before the offending return/yield, which would be inside an except handler and trigger ASYNC120. Detect that case and redirect the insertion to the top of the innermost enclosing loop (if any) or to the top of the function body instead. Fall back to the previous location only for contorted cases where neither of those safer locations would actually break the uncheckpointed path.

Fixes #403.

claude and others added 2 commits April 20, 2026 02:33
The autofix for missing checkpoints (ASYNC910/ASYNC911) used to insert
`await ...checkpoint()` right before the offending return/yield, which
would be inside an except handler and trigger ASYNC120. Detect that case
and redirect the insertion to the top of the innermost enclosing loop
(if any) or to the top of the function body instead. Fall back to the
previous location only for contorted cases where neither of those safer
locations would actually break the uncheckpointed path.

Fixes python-trio#403.
@Zac-HD Zac-HD merged commit 9a49703 into python-trio:main Apr 20, 2026
10 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.

Autofix for missing checkpoints often puts checkpoints inside except blocks (violating ASYNC120)

2 participants