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.

@SAY-5
SAY-5 force-pushed the fix-local-class-constructor-signature-20261001 branch 2 times, most recently from 8e88fbd to c37de97 Compare October 25, 2026 06:07
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.34%. Comparing base (05b25ba) to head (c37de97).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #893   +/-   ##
=======================================
  Coverage   95.34%   95.34%           
=======================================
  Files         134      134           
  Lines       26762    26782   +20     
=======================================
+ Hits        25516    25536   +20     
  Misses       1246     1246           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mcepl
mcepl requested a review from lieryan October 26, 2026 21:04

@mcepl mcepl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge, IMHO.

@SAY-5
SAY-5 force-pushed the fix-local-class-constructor-signature-20261001 branch from c37de97 to 3b24bbf Compare November 16, 2026 20:44

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

2 participants