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

后端 未结 4 2053
执念已碎
执念已碎 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:42

    It's hard when your boss expects single responsibility principle, but pylint says no. So add a second method to your class so your class violates single responsibility principle. How far you are meant to take single responsibility principle is in the eye the beholder.

    My fix,

    I added an extra method to my class, so it now does 2 things.

    def __str__(self):
        return self.__class__.__name__
    

    I'm just wondering if I need to split my class into 2 separate files now, and maybe modules aswell.

    problem solved, but not with my colleagues who spend all day arguing the spec, rather than getting on with it, like it's life and death.

提交回复
热议问题