I’m running Pylint on some code, and receiving the error "Too few public methods (0/2)". What does this message mean?
The Pylint documentation is not helpful:
Used when a class has too few public methods, so be sure it’s really worth it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The error basically says that classes aren’t meant to just store data, as you’re basically treating the class as a dictionary. Classes should have at least a few methods to operate on the data that they hold.
If your class looks like this:
Consider using a dictionary or a
namedtupleinstead. Although if a class seems like the best choice, use it. Pylint doesn’t always know what’s best.Do note that
namedtupleis immutable and the values assigned on instantiation cannot be modified later.