pylint-bot / pylint-unofficial

UNOFFICIAL playground for pylint github migration
0 stars 0 forks source link

Descriptors tagged as "too-few-public-methods" #655

Open pylint-bot opened 9 years ago

pylint-bot commented 9 years ago

Originally reported by: Dylan Baker (BitBucket: dylan_baker)


A descriptor or data descriptor in python implement two or three private methods respectively: init, get, and set (a data descriptor does not have set). The pattern obviously doesn't have any public methods, it's not supposed to.

It would be convenient to have an option similar to the 'mixin' option in pylintrc, such that one could instruct pylint to ignore classes containing 'descriptor' to not issue the 'too-few-public-methods' warning


pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore):


Thanks for the report. I'm actually considering to remove the error entirely, since it tends to get useless.

pylint-bot commented 9 years ago

Original comment by Dylan Baker (BitBucket: dylan_baker):


What about replacing it with a 'class-could-be-callable' error (like the 'method-could-be-function' error)?

Since the problem it's presumably looking for is a pattern like this (obviously this is a super simple example):


class MyClass(object):
    def __init__(self, value):
         self.value = value

    def do(self):
         return self.value

if __name__ == '__main__':
    thing = MyClass('foo')
    thing.do()

This is obviously a bad design since a function, or at the very least the do() method could be replaced with __call__() method, or a more thorough redesign.

pylint-bot commented 9 years ago

Original comment by BitBucket: ceridwenv, GitHub: @ceridwen:


I have this error disabled in Pylint for my own projects since it comes up all the time and is invariably useless.