-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add ignored-parents option to design checker #4758
Add ignored-parents option to design checker #4758
Conversation
This allows users to specify classes to ignore while counting parent classes. Partially closes pylint-dev#3057
3a12ebe
to
d1f9a75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the merge request and the added option, this looks nice. I left some comments. Could you also add a new functional test in tests/functional/.../too_many_ancestors.py with a configuration file, please ?
Co-authored-by: Pierre Sassoulas <[email protected]>
for more information, see https://pre-commit.ci
Added a functional test -- should I keep the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for implementing the functional tests ! It's true that the unittest could be a duplicate now. I don't know for sure if it's covering more line than simply the functional test.
I'll leave it -- it won't hurt and it'll make it easier for the next person who wants to unit test the design checker. |
There will be a slight delay before merging as we want to release 2.9.6 first and this is going in 2.10 🙂 |
Thank you again for your work on this, this will be available in 2.10.0 ! |
Type of Changes
Description
Allow users to specify classes to ignore while counting parent classes.
When one of the ignored classes is detected in the ancestor tree, it and its parents are ignored. Suppose we have the following inheritance diagram:
If we add
E
toignored-parents
, then the classes counted for thetoo-many-ancestors
check will beB
,D
, andC
.If we have another class
G(F)
, thenF
will be counted -- ancestors of ignored parents are pruned from the tree for counting, but we don't go the other way and exclude all parents of ignored parents.Partially closes #3057 by offering a configuration mechanism to ignore non-user classes from counting.
Rationale
typing.Protocol
is ignored from counting, but I'm usingtyping_extensions
, sotyping_extensions.Protocol
is increasing the count and triggering thetoo-many-ancestors
message.