-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Fix duplicate bases error (MROs) with GenericAlias #910
Conversation
9621726
to
23edbea
Compare
23edbea
to
3bbf4d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdce8p thanks for this review.
However i would prefer we wait a little bit to merge it because i think there is probably a better way to handle this.
I would like to dig in a bit more.
astroid/scoped_nodes.py
Outdated
if ( | ||
names | ||
and names[0] is not None | ||
and last_index[names[0]] != 0 | ||
and names[0][1] != "typing._GenericAlias" | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not found of this kind of solution. I think there is maybe something to handle through TypingBrain instead.
However i'm not sure, i'm still investigating this.
By the way on my machine the bug is also present with python 3.9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. Thanks for your work!
By the way on my machine the bug is also present with python 3.9.
Hmm, interesting. MacOS with Py 3.9.2 works. Please let me know if I can help test things, once you have found a better solution.
I took another look at it and even tried to modify After some more investigation, I found that pylint normally would raise a That's when I though about adding a flag to guard the exception during the ast parsing which I've done in the last commit. -- A good test example is: from typing import Sized, Hashable
class Derived(Sized, Hashable):
def __init__(self):
self.var = 1 |
@cdce8p i opened #913 that try to fix the same issue. |
@hippo91 I just saw it. On first glance, your solution does look quite elegant (and way better than mine). I'll run some tests on my code to see if the issue is completely fixed and will get back to you. |
Replaced by #913 |
Steps
Description
Fix duplicate bases error that occurred for Python
<3.9
when using multiple inheritance from_GenericAlias
. Starting with3.9
this is parsed differently as_SpecialGenericAlias
and_BaseGenericAlias
.--
As this is a bug fix, it would be great if it could be included in the next release
2.5.1
.Type of Changes
Related Issue
Closes #905