Skip to content

Fix source regions for regular argument annotations - #887

Open
Strohutt wants to merge 1 commit into
python-rope:masterfrom
Strohutt:fix/argument-annotation-regions
Open

Strohutt wants to merge 1 commit into
python-rope:masterfrom
Strohutt:fix/argument-annotation-regions

Conversation

@Strohutt

Copy link
Copy Markdown

Description

Searching a parameter annotation such as def foo(items: list): ... raises AttributeError because _arg leaves the annotation without a source region. Visit the annotation with the existing child-node handler, following v587su's proposed fix in #802.

Regression tests cover exact source regions, source round trips, wildcard matching, and an actual Restructure replacement of nested annotations with defaults. The change covers regular function arguments.

Fixes #802

Checklist

  • I have added tests that prove my fix is effective
  • I have updated CHANGELOG.md

Validation on Windows with Python 3.12.14: all five new regression tests fail against the original module and pass with the fix. Full suite: 2,153 passed, 12 skipped, 5 xfailed. Targeted Black and isort checks pass; wheel and sdist builds pass.

Visit each argument's annotation so structural searches and replacements
can use its source region. Cover the reported wildcard crash, nested
annotations, defaults, and source round trips.

Based on the diagnosis and proposed fix in issue python-rope#802.

This branch has not been deployed

No deployments
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.

patchedast doesn't consider the annotation of arguments

1 participant