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

Fix too-many-ancestors #4416

Merged
merged 1 commit into from
Apr 28, 2021
Merged

Fix too-many-ancestors #4416

merged 1 commit into from
Apr 28, 2021

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Apr 28, 2021

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

Fix false-positive too-many-ancestors by ignoring pre-defined builtin classes when calculating the number of ancestors. The list isn't complete but should cover most cases.

Type of Changes

Type
βœ“ πŸ› Bug fix

Related Issue

Closes #4166
Closes #4415

@cdce8p cdce8p added this to the 2.8.3 milestone Apr 28, 2021
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 91.642% when pulling 3bbbaa1 on cdce8p:fix-too-many-ancestors into 28c093c on PyCQA:master.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Good job !

@@ -1,2 +1,2 @@
too-many-ancestors:20:0:Iiii:Too many ancestors (9/7)
too-many-ancestors:23:0:Jjjj:Too many ancestors (10/7)
too-many-ancestors:21:0:Iiii:Too many ancestors (8/7)
Copy link
Member

Choose a reason for hiding this comment

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

This actually fixed that test case too, the correct number IS 8 !

Copy link
Member Author

Choose a reason for hiding this comment

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

Depends if you con't object, but it's certainly not false.

@Pierre-Sassoulas Pierre-Sassoulas added the False Positive 🦟 A message is emitted but nothing is wrong with the code label Apr 28, 2021
@Pierre-Sassoulas Pierre-Sassoulas merged commit 24b5159 into pylint-dev:master Apr 28, 2021
@cdce8p cdce8p deleted the fix-too-many-ancestors branch April 28, 2021 19:48
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.8.3, 2.9.0 May 31, 2021
@SagaraBattousai
Copy link

SagaraBattousai commented Mar 11, 2024

I also get this error when inheriting from any normal class (which doesn't cause this error) and a Protocol (which while not necessary is nice to ensure we override the required functions). Whilst we only inherit directly from two classes we get too-many-ancestors 8/7.

This error can be reproduced by:
from setuptools.command.build import SubCommand
from setuptools.command.build_ext import build_ext

# Sub Command is a Protocol but we want to explicitly inherit
class Foo(build_ext, SubCommand):
.....

@Pierre-Sassoulas
Copy link
Member

@SagaraBattousai please open a new issue your comment on a closed issue is going to get lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
4 participants