Skip to content

Conversation

@cdce8p
Copy link
Member

@cdce8p cdce8p commented Dec 12, 2025

This partially fixes pylint-dev/pylint#8425. The additional changes should likely be done in pylint itself.

This does impact the test output for pylint a bit as errors on decorators no longer belong to the function / class now. Not sure that can be avoided though. In any case, I think it's better to do this in 4.1.0 and not in a bugfix release.

@cdce8p cdce8p added this to the 4.1.0 milestone Dec 12, 2025
Comment on lines +2937 to +2938
assert module.locals.get("x") == [name_expr_node1.target]
assert module.locals.get("y") == [name_expr_node2.target]
Copy link
Member Author

Choose a reason for hiding this comment

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

The frame is used for the scope lookup to determine where to assign the variables to. Without the changes in this PR, any variables get assigned to the function / class scope instead even though decorators are evaluated in the module scope.

--
A similar workaround might be required for function argument defaults. Though I haven't searched the issues tracker to see if anyone has complained yet.

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.41%. Comparing base (4448906) to head (8488958).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
astroid/nodes/node_classes.py 71.42% 2 Missing ⚠️

❌ Your patch status has failed because the patch coverage (75.00%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2901      +/-   ##
==========================================
+ Coverage   93.39%   93.41%   +0.02%     
==========================================
  Files          92       92              
  Lines       11214    11229      +15     
==========================================
+ Hits        10473    10490      +17     
+ Misses        741      739       -2     
Flag Coverage Δ
linux 93.28% <75.00%> (+0.02%) ⬆️
pypy 93.41% <75.00%> (+0.02%) ⬆️
windows 93.40% <75.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/nodes/node_ng.py 92.02% <100.00%> (ø)
astroid/nodes/node_classes.py 94.93% <71.42%> (-0.09%) ⬇️

... and 4 files with indirect coverage changes

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

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Make sense to me (both the change and waiting for 4.1), let's hear what Jacob think.

@jacobtylerwalls jacobtylerwalls added the pylint-tested PRs that don't cause major regressions with pylint label Dec 21, 2025
Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

LGTM

@cdce8p cdce8p merged commit 3bc2c06 into pylint-dev:main Dec 22, 2025
18 of 19 checks passed
@cdce8p cdce8p deleted the decorator-frame branch December 22, 2025 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pylint-tested PRs that don't cause major regressions with pylint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unused-variable and undefined-variable with walrus operator

3 participants