Skip to content

Resolve function-local constructor names through their scope - #893

Open
SAY-5 wants to merge 1 commit into
python-rope:masterfrom
SAY-5:fix-local-class-constructor-signature-20261001
Open

SAY-5 wants to merge 1 commit into
python-rope:masterfrom
SAY-5:fix-local-class-constructor-signature-20261001

Conversation

@SAY-5

@SAY-5 SAY-5 commented Oct 2, 2026

Copy link
Copy Markdown

Description

Changing a constructor signature raises AttributeNotFoundError when its class is defined inside a function. The constructor lookup asks the parent function for an attribute, but the local class is stored in its scope.

Resolve the class name through the parent scope. Tests cover selecting the class definition, initializer definition, constructor call, and explicit initializer call; they also verify isolation between same-named local classes and retain a class-nested constructor control.

Fixes #692

Validation

  • Two new regression tests fail on the original code with the reported AttributeNotFoundError; all 43 change-signature tests pass with this change.
  • Full suite on macOS ARM64, Python 3.13.9: 2,156 passed, 7 skipped, 5 xfailed. The run retains existing warnings, including a coverage warning for a deleted temporary fixture.
  • Black 26.5.1: all 96 files selected by the repository configuration pass. git diff --check passes.

Checklist

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

AI assistance: Codex assisted with the implementation, tests, review, and this description.

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.

exception when refactoring method of class defined in function

1 participant