Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize new-style attrs decorators in too-few-public-methods check #9346

Merged

Conversation

akirchhoff-modular
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Beginning with attrs 21.1.0, the recommended way to use attrs is through import attrs and using attrs.define/attrs.frozen, not import attr and attr.s or attr.attrs. Pylint does understand attr.attrs (#2988), but new-style uses of attrs are not understood to be data class decorators.

Modify _is_exempt_from_public_methods to recognize attrs.define and attrs.frozen in a similar way as is currently done with dataclasses.dataclass.

Closes #9345

Beginning with attrs 21.1.0, the recommended way to use attrs is through
`import attrs` and using `attrs.define`/`attrs.frozen`, not `import
attr` and `attr.s` or `attr.attrs`. Pylint does understand `attr.attrs`
(pylint-dev#2988), but new-style uses of attrs are not understood to be data class
decorators.

Modify `_is_exempt_from_public_methods` to recognize `attrs.define` and
`attrs.frozen` in a similar way as is currently done with
`dataclasses.dataclass`.

Closes pylint-dev#9345.
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code backport maintenance/3.1.x labels Jan 4, 2024
@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.0.4 milestone Jan 4, 2024
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 95.81%. Comparing base (511354a) to head (86f4378).
Report is 43 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9346   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files         173      173           
  Lines       18767    18771    +4     
=======================================
+ Hits        17981    17985    +4     
  Misses        786      786           
Files Coverage Ξ”
pylint/checkers/design_analysis.py 98.90% <100.00%> (+0.02%) ⬆️

Copy link
Contributor

github-actions bot commented Jan 4, 2024

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit 86f4378

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.

Thanks!

@jacobtylerwalls jacobtylerwalls merged commit c032181 into pylint-dev:main May 4, 2024
54 checks passed
github-actions bot pushed a commit that referenced this pull request May 4, 2024
…9346)

Beginning with attrs 21.1.0, the recommended way to use attrs is through
`import attrs` and using `attrs.define`/`attrs.frozen`, not `import
attr` and `attr.s` or `attr.attrs`. Pylint does understand `attr.attrs`
(#2988), but new-style uses of attrs are not understood to be data class
decorators.

Modify `_is_exempt_from_public_methods` to recognize `attrs.define` and
`attrs.frozen` in a similar way as is currently done with
`dataclasses.dataclass`.

Closes #9345.

(cherry picked from commit c032181)
jacobtylerwalls pushed a commit that referenced this pull request May 4, 2024
…9346) (#9596)

Beginning with attrs 21.1.0, the recommended way to use attrs is through
`import attrs` and using `attrs.define`/`attrs.frozen`, not `import
attr` and `attr.s` or `attr.attrs`. Pylint does understand `attr.attrs`
(#2988), but new-style uses of attrs are not understood to be data class
decorators.

Modify `_is_exempt_from_public_methods` to recognize `attrs.define` and
`attrs.frozen` in a similar way as is currently done with
`dataclasses.dataclass`.

Closes #9345.

(cherry picked from commit c032181)

Co-authored-by: akirchhoff-modular <github-work@kirchhoff.digital>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport maintenance/3.1.x False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New-style attrs decorators not recognized as data class decorators
3 participants