Skip to content
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

Don't show astroid.DuplicateBasesError for attribute access #4317

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Release date: Undefined

Closes #3850

* Don't show ``DuplicateBasesError`` for attribute access


What's New in Pylint 2.7.4?
===========================
Expand Down
2 changes: 2 additions & 0 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ def visit_attribute(self, node):
continue
except AttributeError:
continue
except astroid.DuplicateBasesError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
except astroid.DuplicateBasesError:
except astroid.DuplicateBasesError:
# See https://github.com/PyCQA/pylint/pull/4317

Copy link
Member Author

@cdce8p cdce8p Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is worth it. For one, you can get this information via git blame. Additionally the added test will catch if it's missing.

continue
except astroid.NotFoundError:
# This can't be moved before the actual .getattr call,
# because there can be more values inferred and we are
Expand Down
5 changes: 4 additions & 1 deletion tests/functional/d/duplicate_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# pylint: disable=missing-docstring,too-few-public-methods,no-init


class Duplicates(str, str): # [duplicate-bases]
class Duplicates(str, str): # [duplicate-bases]
pass


Expand All @@ -13,3 +13,6 @@ class Alpha(str):
class NotDuplicates(Alpha, str):
"""The error should not be emitted for this case, since the
other same base comes from the ancestors."""


print(Duplicates.__mro__)