-
-
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 Positive on E1101 no-member with property + inheritance + Generic #3684
Comments
Happens with the collections.abc objects too, as they are aliased by the typing module. from typing import MutableMapping
class test(MutableMapping[str, int]):
def __init__(self):
self._data = {}
def __getitem__(self, key):
return self._data[key]
def __setitem__(self, key, value):
self._data[key] = value
def __delitem__(self, key):
del self._data[key]
def __iter__(self):
return iter(self._data)
def __len__(self):
return len(self._data)
a = test()
a.keys() Results in:
|
This might be the same issue:
results in:
It seems like these generic types like |
Could be related to #3131 |
Yes, I think that is very likely. I tried to implement a solution in Astroid, but while I figured out why it didn't work, it wasn't clear to me how Astroid's internals are supposed to operate. If someone with a better understanding of Astroid's internals could answer these questions, I could continue with the PR. |
It seems like Pylint does not understand some of our descriptors (e.g. `_PubProperty`) well enough and thus raises false-positive `no-member´ warnings. This seems to be a know issue. If someone fixes pylint-dev/pylint#3684, we can revert this commit. Adding local disable-statements would be much effort. It seems better to wait and further improve our type hints in the meantime, so that Mypy can step in to catch potential `no-member` bugs.
For pylint 2.7, this warning appears multiple times and is related to using the `augment_excmessage` function of module `objecttools`. Pylint does not understand that this function never returns. I opened issue pylint-dev/pylint#4122. Once accepted and implemented, we can reverse this commit. If the proposal is rejected, we have to decide whether we want to keep the global setting or write the corresponding comment to each individual corresponding function call. It seems like Pylint does not understand some of our descriptors (e.g. `_PubProperty`) well enough and thus raises false-positive `no-member´ warnings. This seems to be a know issue. If someone fixes pylint-dev/pylint#3684, we can revert this commit. Adding local disable-statements would be much effort. It seems better to wait and further improve our type hints in the meantime, so that Mypy can step in to catch potential `no-member` bugs.
For my repro above, I believe this issue no longer happens in pylint 2.7. Still happens for @xrogaan's repro though. |
I'm still having the same error with |
Closing as it must have been fixed between 2.11.1 and 2.15 because I can't reproduce with any of the examples given. |
Before I begin, I just want to say Pylint is awesome. When I update from Python 3.6.5 to Python 3.8.2, it helped me figure out which built-in libraries had their API's changed (ex:
time.clock
's removal).However, when I updated from 3.6.5 to 3.8.2, I discovered a Pylint bug as well. I would like to report a false positive on
E1101, no-member
.I have found that when using a certain combination of:
typing.Generic
property
That pylint erroneously reports
no-member
.Steps to reproduce
In the below code, you can see:
base_property
is aproperty
BaseClass
is a subclass ofGeneric
base_property
is type hinted with aTypeVar
BaseClass
is subclassed twice -->GrandchildClass
Pylint output:
At runtime, this code works fine.
Expected behavior
I believe the above code sample should not raise a
no-member
.Note: this behavior depends on the Python version:
pylint --version output
The text was updated successfully, but these errors were encountered: