-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
member lookup with Generic base class in 2.5.3 #942
Comments
We are experiencing the same issue with Astroid 2.5.3, rolling back to 2.5.2 addresses it. We suspect it was introduced by: cd0f896 |
I can confirm the issue. #931 might indeed be related but I don't believe it's the sole reason. After some investigation, I found that the ancestors of from astroid import builder
def test_ancestors_with_generics():
tree = builder.parse(
"""
from typing import TypeVar, Generic
T = TypeVar("T")
class A(Generic[T]):
def a_method(self):
print("hello")
class B(A[T]): pass
class C(B[str]): pass
"""
)
node_b = tree["B"]
inferred_b = next(node_b.infer())
ancestors_b = list(inferred_b.ancestors())
assert [cdef.name for cdef in ancestors_b] == ["A", "Generic", "object"]
node_c = tree["C"]
inferred_c = next(node_c.infer())
ancestors_c = list(inferred_c.ancestors())
assert [cdef.name for cdef in ancestors_c] == ["B", "A", "Generic", "object"] # fails!
test_ancestors_with_generics() At the moment, only @hippo91 Do you have an idea how to fix that? It's probably related to the changes in |
@cdce8p i just had a look to the pb. In fact the ancestors method failed at line
in fact this is the
I will try to investigate at bit more ASAP, but a sure thing is that, IMHO, we definitely need #927 |
@hippo91 and @cdce8p: both your test and the
I've pushed my this to https://github.com/nelfin/astroid/tree/fix/942-merge on my fork if you'd like to try something else. |
@nelfin nice catch! |
This issue is fixed in the current |
Steps to reproduce
Current behavior
pylint fails with
22:0: E1101: Instance of 'C' has no 'a_method' member (no-member)
when using astroid 2.5.3 but doesn't when using astroid 2.5.2Expected behavior
python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
outputWhen failing:
Without failing:
The text was updated successfully, but these errors were encountered: