-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Is too-few-public-methods (R0903) really useful? #2710
Comments
Can you provide examples here? External sites may be changed so link only reports are not too useful. |
And the first example that I spotted, in https://stackoverflow.com/a/14027686/4130619 is a case where complaint makes a perfect sense. |
@uriva As mentioned by @matkoniecz in most cases the check makes sense. If your class has a single method on it, it's probably a function in disguise. You can also configure the number of public methods with min-public-methods. But there are a couple of classes for which we should not report this, as it makes perfect sense to not have too many methods or no methods at all. This includes |
Ok. |
@matkoniecz @PCManticore there is one false positive where this really shouldn't trigger. Descriptors (or class-based properties) contain only dunders (which are not technically private methods anyway since many can be called directly):
I don't remember if single-method classes trigger, but a lot of common OOP design patterns use these (Additionally mixins can be lumped in this as well).
It's probably fine to trigger on though, but IMO a bit inaccurate in that Python is intended to be an OOP first language. |
it may be better to open new issue over commenting in 2019 one |
Ok, I'll create a new issue and reference this for @uriva. |
This message over triggers many times, e.g. for dataclasses (or at least the backport to python 3.6).
See other examples in https://stackoverflow.com/questions/14027417/what-does-pylints-too-few-public-methods-message-mean
Consider removing altogether.
The text was updated successfully, but these errors were encountered: