-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Enhancement ✨Improvement to a componentImprovement to a componentFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the code
Milestone
Description
Simply inheriting from collections.abc.MutableSequence generates a too-many-ancestors refactoring warning.
Yes, it does have that many ancestors, but I would consider only classes from the stdlib that are actually inherited by user code to be counted towards max ancestors.
And yes, I can disable this error in this case, or increase the max ancestors count, but it feels wrong to do that when just using the collections hierarchy for its intended purpose.
Steps to reproduce
For a minimal MutableSequence implemented, ancestor.py:
from collections.abc import MutableSequence
class ItemSequence(MutableSequence):
"""Minimal MutableSequence."""
def __getitem__(self, key):
return key
def __setitem__(self, key, value):
_ = key, value
def __delitem__(self, key):
_ = key
def insert(self, index, value):
_ = index, value
def __len__(self):
return 1pylint ancestor.py returns:
ancestor.py:4:0: R0901: Too many ancestors (8/7) (too-many-ancestors)
Expected behavior
Inheriting from a stdlib class shouldn't generate a Refactor warning.
pylint --version output
Result of pylint --version output:
pylint 2.7.4
astroid 2.5.2
Python 3.7.7 (default, Aug 8 2019, 00:00:00)
[GCC 8.3.1 20190311 (Red Hat 8.3.1-3)]
Metadata
Metadata
Assignees
Labels
Enhancement ✨Improvement to a componentImprovement to a componentFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the code