pylint
pylint copied to clipboard
no-member false positive from NewType
This is a weird interaction between the typing library and pylint, so I'm not sure if this is the right place to file the bug, but here goes.
Steps to reproduce
from typing import NewType
class A:
def __init__(self, value: int):
self.value = value
a = A(5)
a.value # no no-member error
B = NewType("B", A)
b = B(a)
b.value # Instance of 'B' has no 'value' memberpylint(no-member)
Current behavior
Pylint flags a no-member error when accessing members of objects with a NewType class.
Expected behavior
Pylint flags no errors.
pylint --version output
pylint 2.4.2 astroid 2.3.1 Python 3.7.4 (default, Sep 20 2019, 11:46:08) [GCC 8.3.0]
Thanks for reporting the issue. We currently do not support NewType
but it's something we can add in astroid
.
Looks like a duplicate of #2296. Are there any plans of fixing this soon? This is a real show-stopper for pylint in projects which take typing a bit more seriously.
@svenpanne Feel free to start working on this yourself. This project currently has ~500 opened issues and overburdened maintainers so your "pet" issue might not be fixed "soon". After all, the code is open source, feel free to fork the project and do whatever you want with it.
Well, my proposal is simply to revert the commit mentioned in #2296, as it obviously does more harm than good...