-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
attrs: wrong type inferred from Factory attribute (using auto_attribs) #4341
Closed
belm0 opened this issue
Apr 12, 2021
· 3 comments
· Fixed by pylint-dev/astroid#2126 or pylint-dev/astroid#2303
Closed
attrs: wrong type inferred from Factory attribute (using auto_attribs) #4341
belm0 opened this issue
Apr 12, 2021
· 3 comments
· Fixed by pylint-dev/astroid#2126 or pylint-dev/astroid#2303
Labels
Bug 🪲
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs astroid Brain 🧠
Needs a brain tip in astroid (then an astroid upgrade)
Milestone
Comments
@belm0 thanks for your report. Would it be possible to have smaller reproducer? For example without |
hippo91
added
Bug 🪲
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs astroid Brain 🧠
Needs a brain tip in astroid (then an astroid upgrade)
labels
May 13, 2021
confirmed it's not related to numpy: import attr
@attr.attrs(auto_attribs=True)
class Foo:
position: int = attr.Factory(lambda: 3)
#position: int = attr.attrib(default=attr.Factory(lambda: 3)) # this works
def bar(self):
return -self.position
|
@belm0 thanks for this update! |
AChenQ
pushed a commit
to AChenQ/tensorbay-python-sdk
that referenced
this issue
May 19, 2021
pylint get annotation by function return not `__annotations__`, so that it think `attr()` return a Field object, will raise assigning-non-slot and no-member error do the following for skip pylint check * annotating slot to skip assigning-non-slot error * add "__getattr__" function to skip no-member error related issue pylint-dev/pylint#4341
AChenQ
pushed a commit
to AChenQ/tensorbay-python-sdk
that referenced
this issue
May 19, 2021
pylint get annotation by function return not `__annotations__`, so that it think `attr()` return a Field object, will raise assigning-non-slot and no-member error do the following for skip pylint check * annotating slot to skip assigning-non-slot error * add "__getattr__" function to skip no-member error related issue pylint-dev/pylint#4341
AChenQ
pushed a commit
to AChenQ/tensorbay-python-sdk
that referenced
this issue
May 19, 2021
pylint get annotation by function return not `__annotations__`, so that it think `attr()` return a Field object, raised error `E0237: Assigning to attribute 'box2d' not defined in class slots (assigning-non-slot)` `E1101: Instance of 'Field' has no 'box3d' member (no-member)` do the following for skip pylint check * annotating slot to skip assigning-non-slot error * add "__getattr__" function to skip no-member error related issue pylint-dev/pylint#4341
AChenQ
pushed a commit
to AChenQ/tensorbay-python-sdk
that referenced
this issue
May 19, 2021
`attr()` returns `Field` as the class variables value, using type hint as the real type of variables. pylint use `Field` as the variable type, so it will report the following errors `E0237: Assigning to attribute 'box2d' not defined in class slots (assigning-non-slot)` `E1101: Instance of 'Field' has no 'box3d' member (no-member)` do the following as a workaround for pylint errors * remove `__slot__` for E0237 * add `__getattr__` function for E1101 related issue: pylint-dev/pylint#4341
AChenQ
pushed a commit
to AChenQ/tensorbay-python-sdk
that referenced
this issue
May 19, 2021
`attr()` returns `Field` as the class variables value, using type hint as the real type of variables. pylint use `Field` as the variable type, so it will report the following errors `E0237: Assigning to attribute 'box2d' not defined in class slots (assigning-non-slot)` `E1101: Instance of 'Field' has no 'box3d' member (no-member)` do the following as a workaround for pylint errors * remove `__slot__` for E0237 * add `__getattr__` function for E1101 related issue: pylint-dev/pylint#4341 PR Closed: Graviti-AI#580
AChenQ
pushed a commit
to Graviti-AI/tensorbay-python-sdk
that referenced
this issue
May 19, 2021
`attr()` returns `Field` as the class variables value, using type hint as the real type of variables. pylint use `Field` as the variable type, so it will report the following errors `E0237: Assigning to attribute 'box2d' not defined in class slots (assigning-non-slot)` `E1101: Instance of 'Field' has no 'box3d' member (no-member)` do the following as a workaround for pylint errors * remove `__slot__` for E0237 * add `__getattr__` function for E1101 related issue: pylint-dev/pylint#4341 PR Closed: #580
mbyrnepr2
added a commit
to mbyrnepr2/astroid
that referenced
this issue
Apr 19, 2023
…ecorated with ``attrs``. Closes pylint-dev/pylint#4341
DanielNoord
pushed a commit
to pylint-dev/astroid
that referenced
this issue
Apr 19, 2023
…ecorated with ``attrs``. Closes pylint-dev/pylint#4341
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug 🪲
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs astroid Brain 🧠
Needs a brain tip in astroid (then an astroid upgrade)
Steps to reproduce
attrs allows this form for factory, but pylint doesn't understand it:
Current behavior
Expected behavior
no error
pylint --version output
Result of
pylint --version
output:Additional dependencies:
The text was updated successfully, but these errors were encountered: