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 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.37%. Comparing base (4448906) to head (9684a0b).
⚠️ Report is 8 commits behind head on main.

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

❌ Your patch check has failed because the patch coverage (66.66%) 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.37%   -0.02%     
==========================================
  Files          92       92              
  Lines       11214    11220       +6     
==========================================
+ Hits        10473    10477       +4     
- Misses        741      743       +2     
Flag Coverage Δ
linux 93.24% <66.66%> (-0.02%) ⬇️
pypy 93.37% <66.66%> (-0.02%) ⬇️
windows 93.36% <66.66%> (-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_classes.py 94.93% <66.66%> (-0.09%) ⬇️

... and 3 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.

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.

unused-variable and undefined-variable with walrus operator

2 participants