What does pylint's “Too few public methods” message mean

后端 未结 4 2045
执念已碎
执念已碎 2020-12-24 04:29

I\'m running pylint on some code, and receiving the error \"Too few public methods (0/2)\". What does this message mean? The pylint docs are not helpful:

4条回答
  •  鱼传尺愫
    2020-12-24 04:55

    If you are extending a class, then my suggestion is to systematically disable this warning and move on, e.g., in the case of Celery tasks:

    class MyTask(celery.Task):  # pylint: disable=too-few-public-methods                                                                                   
        """base for My Celery tasks with common behaviors; extends celery.Task
    
        ...             
    

    Even if you are only extending a single function, you definitely need a class to make this technique function, and extending is definitely better than hacking on the third-party classes!

提交回复
热议问题