Skip to content

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

Development

Successfully merging this pull request may close these issues.

too-many-ancestors when inheriting from collections.abc.MutableSequence false positive too-many-ancestors if class inherits MutableMapping

4 participants