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
Duplicates found in MROs (OrderedSet) #905
Duplicates found in MROs (OrderedSet) #905
Comments
Found a similar issue with
Interestingly the error occurred when using Python 3.8. However, 3.9 was fine. # test_pylint.py
# pylint: disable=missing-class-docstring,inherit-non-class,too-few-public-methods
# pylint: disable=no-value-for-parameter,unused-import,missing-module-docstring
# pylint: disable=super-init-not-called
import abc
from typing import Sized, Iterable
class AbstractRoute(abc.ABC):
pass
class AbstractResource(Sized, Iterable["AbstractRoute"]):
pass
class IndexView(AbstractResource):
def __init__(self):
self.var = 1 Running
|
One solution might be to add an additional condition to the check in Replacing if (
names
and names[0] is not None
and last_index[names[0]] != 0
and names[0][1] != "typing._GenericAlias"
): does work. I just don't know enough about the way astroid works to know if that's a good fix. -- As for Python 3.9: There it seems to be |
commit 3bbf4d2 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue Feb 23 01:48:29 2021 +0100 Add test cases for duplicate bases error commit 934264d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon Feb 22 11:00:48 2021 +0100 Fix duplicate bases error for typing._GenericAlias * Fixes pylint-dev#905
commit 80fac24471980dffc5831153fb5faac6690c4adf Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat Feb 27 15:46:18 2021 +0100 Use flag to guard DuplicateBasesError commit 3bbf4d2 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue Feb 23 01:48:29 2021 +0100 Add test cases for duplicate bases error commit 934264d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon Feb 22 11:00:48 2021 +0100 Fix duplicate bases error for typing._GenericAlias * Fixes pylint-dev#905
commit bc872b73dcdefd87959e08f3942fe8c0a4a746d8 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat Feb 27 15:46:18 2021 +0100 Use flag to guard DuplicateBasesError commit 3bbf4d2 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue Feb 23 01:48:29 2021 +0100 Add test cases for duplicate bases error commit 934264d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon Feb 22 11:00:48 2021 +0100 Fix duplicate bases error for typing._GenericAlias * Fixes pylint-dev#905
commit 3f9089a924224be472ab4856a4cdb53df9b947a3 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat Feb 27 15:46:18 2021 +0100 Use flag to guard DuplicateBasesError commit 3bbf4d2 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue Feb 23 01:48:29 2021 +0100 Add test cases for duplicate bases error commit 934264d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon Feb 22 11:00:48 2021 +0100 Fix duplicate bases error for typing._GenericAlias * Fixes pylint-dev#905
commit 00b9fdb81405063afe825c7a687ea82de020a41d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat Feb 27 15:46:18 2021 +0100 Use flag to guard DuplicateBasesError commit 3bbf4d2 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue Feb 23 01:48:29 2021 +0100 Add test cases for duplicate bases error commit 934264d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon Feb 22 11:00:48 2021 +0100 Fix duplicate bases error for typing._GenericAlias * Fixes pylint-dev#905
commit b151e80 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat Feb 27 15:46:18 2021 +0100 Use flag to guard DuplicateBasesError commit 3bbf4d2 Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue Feb 23 01:48:29 2021 +0100 Add test cases for duplicate bases error commit 934264d Author: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon Feb 22 11:00:48 2021 +0100 Fix duplicate bases error for typing._GenericAlias * Fixes pylint-dev#905
* Adds inference support for all typing types that are defined through _alias function * Instead of creating a new class (by the mean of TYPING_TYPE_TEMPLATE) infer the origin class : i.e MutableSet = _alias(collections.MutableSet ...) origin is the class in collections module. Needs to add __getitem method on its metaclass so that is support indexing (MutableSet[T]). * Enable _alias mocking and testing only if python version is at least 3.7 Co-authored-by: hippo91 <guillaume.peillex@gmail.com>
@hippo91 We did our best do today to merge the fix. I believe we got it. Since you have some more experience with Since everything seems to be fine at the moment, there is no rush. Just let me know once you did so I know what to do better next time. Thanks for your help getting this fix over the finish line. |
@cdce8p @Pierre-Sassoulas thanks a lot and congrats for having been able to release so fast. |
@cdce8p i took a look at #906 and overall it looks good. I just have two interrogations: All in all it is a good job. Thanks again for taking time to achieve it. |
@hippo91 An issue I noticed without the intermediate class / metaclass was that The one thing I'm not so sure about is the MRO for import collections.abc
class Derived(collections.abc.Iterator[int]):
pass During testing I noticed that it was only |
@cdce8p it makes sense. Thanks for your explanations. |
Steps to reproduce
This issue is directly linked to pylint-dev/pylint#4093
Current behavior
Expected behavior
No error. It was the case with
astroid 2.4.2
. A bisection leads to commit 7f1d513.python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output2.5
The text was updated successfully, but these errors were encountered: