Fix ASYNC200 regression on foo("x").bar patterns (#26.4.2)#455
Merged
Zac-HD merged 3 commits intopython-trio:mainfrom May 1, 2026
Merged
Fix ASYNC200 regression on foo("x").bar patterns (#26.4.2)#455Zac-HD merged 3 commits intopython-trio:mainfrom
foo("x").bar patterns (#26.4.2)#455Zac-HD merged 3 commits intopython-trio:mainfrom
Conversation
The canonical-qualname resolver introduced in 26.4.1 recursed through
ast.Call/cst.Call unconditionally, which collapsed nested calls inside an
attribute chain into a dotted name (e.g. `read_session("a").get` resolved
to `read_session.get`). This caused user-configured ASYNC200 patterns
like `*session.get` to flag method calls on the return value of an
unrelated function -- a false positive that did not exist in 25.5.3.
Only unwrap Call at the outermost position; calls inside an attribute
chain now make the whole expression unresolvable (None), since the
target of the trailing attribute is a return value we can't determine
statically. Top-level shapes like `trio.open_nursery()` still resolve
as before.
Adds:
- eval-file regression case in tests/eval_files/async200.py
- direct unit test for resolve_canonical_ast / resolve_canonical_cst
- changelog entry for 26.4.2 and version bump
https://claude.ai/code/session_01BWheK2fZPMDhbfS1LCR2zc
for more information, see https://pre-commit.ci
- Move `resolve_canonical_ast` / `resolve_canonical_cst` import to the top of tests/test_flake8_async.py (ruff PLC0415 / import-not-at-top). - Black reformat of `_resolve_attr_chain_ast` signature. https://claude.ai/code/session_01BWheK2fZPMDhbfS1LCR2zc
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.
The canonical-qualname resolver introduced in 26.4.1 recursed through ast.Call/cst.Call unconditionally, which collapsed nested calls inside an attribute chain into a dotted name (e.g.
read_session("a").getresolved toread_session.get). This caused user-configured ASYNC200 patterns like*session.getto flag method calls on the return value of an unrelated function -- a false positive that did not exist in 25.5.3.Only unwrap Call at the outermost position; calls inside an attribute chain now make the whole expression unresolvable (None), since the target of the trailing attribute is a return value we can't determine statically. Top-level shapes like
trio.open_nursery()still resolve as before.Adds:
https://claude.ai/code/session_01BWheK2fZPMDhbfS1LCR2zc