-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
brain_attrs doesn't add PEP 526 instance variable annotations, causing no-member
errors
#2514
Milestone
Comments
Hnasar
added a commit
to Hnasar/astroid
that referenced
this issue
Aug 23, 2024
Similar to dataclasses, the following class which uses instance variable annotations is valid: ```py @attrs.define class AttrsCls: x: int AttrsCls(1).x ``` However, before this commit astroid failed to transform the class attribute into an instance attribute and this led to `no-member` errors in pylint. Only the new `attrs` API supports this form out-of-the-box, so just address the common case. Closes pylint-dev#2514
Pierre-Sassoulas
pushed a commit
that referenced
this issue
Aug 27, 2024
Similar to dataclasses, the following class which uses instance variable annotations is valid: ```py @attrs.define class AttrsCls: x: int AttrsCls(1).x ``` However, before this commit astroid failed to transform the class attribute into an instance attribute and this led to `no-member` errors in pylint. Only the new `attrs` API supports this form out-of-the-box, so just address the common case. Closes #2514
Marking as blocker to ensure we forwardport the fix before the next feature release. |
I guess we'll just take care of the forwardport when merging maintenance into main. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce
In some contexts, Pylint issues a false positive with an attrs class with only a type annotation (see PEP 526. If we add the attribute via the astroid brain_attrs then this fixes the issue. (I'm not sure if this is a duplicate of #724 ). This is supported at runtime with the newer
attrs
decorators.Current behavior
Expected behavior
No error
The text was updated successfully, but these errors were encountered: