-
-
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
False negative and false positive 'no-member' errors with +=
#4562
Comments
There is also a false positive case. Prerequisitepip install pydantic Steps to reproduceGiven a file # pylint: disable=missing-module-docstring
# pylint: disable=too-few-public-methods
# pylint: disable=missing-class-docstring
# pylint: disable=invalid-name
from pydantic import BaseModel
class A(BaseModel):
value: int
obj = A(value=1)
obj.value += 1 Current behavior$ pylint d.py
************* Module d
d.py:13:0: E1101: Instance of 'A' has no 'value' member (no-member)
-----------------------------------
Your code has been rated at 0.00/10 Expected behaviorThis one should be OK. |
+=
The false negative in the original post is related to the below code in
We correctly exclude instances of However, we do not exclude cases like in the false negative where the assignment is reliant on the value being checked less explicitly, e.g. |
Hi, I'm going to try to work on this issue as a first issue. |
I took a stab at fixing this issue but came across a roadblock. Basically, pylint correctly identifies
but it doesn't identify So I tried to add breakpoints and try to make the two be equivalent, by adding
As a starting point, but this gave some other failures in other tests. Any ideas from the maintainers? |
I would check what is inside the AST node when the code is |
I think you'll need a |
I'm getting a bit closer with this check
because it checks that we're assigning and that there's a bin operation to +
which is fair... I have to somehow figure out if the assigning is to ITSELF, but the object ids are different: in |
You might want to check if we don't have a helper function for this in attr_node.target.name in {x.left.name, x.right.name} |
Steps to reproduce
Given a file
a.py
:Given a file
b.py
:Given a file
c.py
:Current behavior
Results:
Expected behavior
There should also be
no-member
issues inb.py
andc.py
.pylint --version output
Result of
pylint --version
output:The text was updated successfully, but these errors were encountered: