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

New-style attrs decorators not recognized as data class decorators #9345

Closed
akirchhoff-modular opened this issue Jan 4, 2024 · 0 comments · Fixed by #9346
Closed

New-style attrs decorators not recognized as data class decorators #9345

akirchhoff-modular opened this issue Jan 4, 2024 · 0 comments · Fixed by #9346
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Milestone

Comments

@akirchhoff-modular
Copy link

akirchhoff-modular commented Jan 4, 2024

Bug 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.

"""Example module"""

from attrs import define


@define
class Coordinates:
    """An integer X/Y coordinate on the Cartesian coordinate plane."""

    x: int
    y: int

Configuration

No response

Command used

pylint example.py

Pylint output

************* Module example
example.py:7:0: R0903: Too few public methods (0/2) (too-few-public-methods)

Expected behavior

I expect the code to pass pylint without triggering the too-few-public-methods check.

Pylint version

pylint 3.0.3
astroid 3.0.2
Python 3.9.6 (default, Oct 18 2022, 12:41:40) 
[Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

No response

Additional dependencies

attrs==23.2.0
@akirchhoff-modular akirchhoff-modular added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 4, 2024
akirchhoff-modular added a commit to akirchhoff-modular/pylint that referenced this issue Jan 4, 2024
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 this to the 3.0.4 milestone Jan 4, 2024
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 4, 2024
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 3.0.4, 3.1.1 Feb 23, 2024
jacobtylerwalls pushed a commit that referenced this issue 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.
github-actions bot pushed a commit that referenced this issue 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 issue 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
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants