Skip to content

Conversation

zenlyj
Copy link
Contributor

@zenlyj zenlyj commented Sep 2, 2025

Type of Changes

Type
βœ“ πŸ› Bug fix
✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

This is related to pylint #10525. When a class is decorated with attrs.define, attributes are treated as instance variables, unless they are explicitly annotated with typing.ClassVar. However, the attrs brain transforms all class attributes into instance attributes, including those with ClassVar type annotation.

This update fixes that behavior by ensuring that attributes annotated with ClassVar are skipped during the transformation.

Copy link

codecov bot commented Sep 2, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 93.35%. Comparing base (66b716c) to head (a11d343).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2811      +/-   ##
==========================================
+ Coverage   93.31%   93.35%   +0.03%     
==========================================
  Files          91       91              
  Lines       11094    11100       +6     
==========================================
+ Hits        10352    10362      +10     
+ Misses        742      738       -4     
Flag Coverage Ξ”
linux 93.21% <100.00%> (+0.03%) ⬆️
pypy 93.35% <100.00%> (+0.03%) ⬆️
windows 93.33% <100.00%> (+0.03%) ⬆️

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

Files with missing lines Coverage Ξ”
astroid/brain/brain_attrs.py 100.00% <100.00%> (ΓΈ)
astroid/brain/brain_dataclasses.py 93.85% <100.00%> (+0.53%) ⬆️
astroid/brain/helpers.py 100.00% <100.00%> (ΓΈ)

... and 1 file with indirect coverage changes

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

@zenlyj zenlyj force-pushed the update-brain-attrs branch 3 times, most recently from d5421ed to a768ecd Compare September 3, 2025 17:19
Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Amazing, thanks!

Sorry I forgot about this, but could you add a Changelog entry?

@zenlyj zenlyj force-pushed the update-brain-attrs branch from a768ecd to a11d343 Compare September 4, 2025 14:02
@DanielNoord DanielNoord merged commit 17c4391 into pylint-dev:main Sep 4, 2025
19 checks passed
@zenlyj zenlyj deleted the update-brain-attrs branch September 4, 2025 14:14
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.

2 participants