pylint-bot / pylint-unofficial

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

warn when a static or a class method is declared without a decorator #675

Closed pylint-bot closed 8 years ago

pylint-bot commented 9 years ago

Originally reported by: Laura Médioni (BitBucket: lmedioni, GitHub: @lmedioni?)


Emit a warning when a static method or a class method is declared without using decorators syntax.

Example:

class MyClass(object):
    def my_method(cls):
        pass
    my_method = classmethod(my_method)

should trigger a warning


pylint-bot commented 9 years ago

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


This sounds like a good idea in general, but it should be a refactoring message rather than a warning. It should verify only when the assignment is at a class scope and only if the classmethod's argument belongs to the class where it is defined. That's because we can use something like this for satisfying an API:

#!python

class MyClass(SomeBaseClass):
    _make = classmethod(tuple.__new__)
pylint-bot commented 9 years ago

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


Closed by https://bitbucket.org/logilab/pylint/pull-requests/295/check-for-class-methods-declared-without-a/diff