Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:37:45+00:00 2026-06-17T13:37:45+00:00

Pylint keeps reporting an error ( R: 73,0:MyLogging: Too many public methods (22/20) )

  • 0

Pylint keeps reporting an error (R: 73,0:MyLogging: Too many public methods (22/20)) for the following code:

class MyLogging(logging.Logger):

    def foo(self):
        pass

    def bar(self):
        pass

At first I thought it was a bug in Pylint since the MyLogging class had exactly 22 lines of code, but then I realized, that it was including all public methods from the base class logging.Logger as well, which added 20 to the statistics.

Is it possible to exclude base classes’ public methods from Pylint statistics?

PS.: I’m aware I can change max-public-methods to a higher number, or add a one-time exception with # pylint: disable=R0904

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:37:46+00:00Added an answer on June 17, 2026 at 1:37 pm

    There are ways, but none of them are good.

    This is not configurable: you can check the code in Pylint’s design_analysis.MisdesignChecker, within def leave_class:

    for method in node.methods():
        if not method.name.startswith('_'):
            nb_public_methods += 1
    

    The above code simply iterates over all methods not starting with "_" and counts them as public methods.

    Consequently, I see two ways to do what you want to do:

    1. fork Pylint and modify this method:

       for method in node.methods():
           if not method.name.startswith('_') and method.parent == node:
               nb_public_methods += 1
      

      method.parent – the class node where this function is defined; also in your leave_class function you have a parameter node – which is the class node.

      Comparing them you can understand if it is the current class or not.

    2. disable this rule in the Pylint configuration and create you own plugin:

       MAX_NUMBER_PUBLIC_METHODS = 3
       class PublicMethodsChecker(BaseChecker):
           __implements__ = (IASTNGChecker,)
      
           name = 'custom-public-methods-checker'
      
           msgs = {
               "C1002": ('Too many public methods (%s/%s)',
                     'Used when class has too many public methods, try to reduce \
                      this to get a more simple (and so easier to use) class.'),
           }
      
           def leave_class(self, node):
               """check number of public methods"""
               nb_public_methods = 0
               print type(node)
               for method in node.methods():
                   if not method.name.startswith('_') and method.parent == node:
                       nb_public_methods += 1
               if nb_public_methods > MAX_NUMBER_PUBLIC_METHODS:
                    self.add_message('C1002',
                                node=node,
                                args=(nb_public_methods, MAX_NUMBER_PUBLIC_METHODS))
      

      Basically, this implementation is the slightly modified excerpt of design_analysis.MisdesignChecker from the Pylint source code.

    For more information about plugins, see Helping pylint to understand things it doesn’t, and in the Pylint source code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running Pylint on some code, and receiving the error "Too few public methods
In python i'm following camelCase Naming style. I checked my code with pylint and
For the following simple wxPython snippets: import sys import wx class MyApp(wx.App): def OnInit(self):
Pylint says W: 6: Using possibly undefined loop variable 'n' ... with this code:
I am trying to use pylint to generate uml diagramms for jython code. If
I just ran pylint on my code and it shows up this message: Uses
I have a python class and ran pylint against it. One message it gave
I'm testing my project using pylint and currently getting fatal error when importing the
Which static code analyzer (if any) do you use? I've been using PyLint for
I am using pylint utility that returns this error codes: Pylint should leave with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.