Skip to content

Files

Latest commit

 

History

History
43 lines (27 loc) · 820 Bytes

unexpected-special-method-signature.md

File metadata and controls

43 lines (27 loc) · 820 Bytes

Pattern: Unexpected special method signature

Issue: -

Description

Emitted when a special method was defined with an invalid number of parameters. If it has too few or too many, it might not work at all.

Example of incorrect code:

class Invalid(object):

    def __enter__(self, other):
        pass

    def __format__(self, other, other2):
        pass

    def __round__(self, invalid, args):
        pass

Example of correct code:

class Valid(object):

    @staticmethod
    def __enter__():
        pass
        
    def __format__(self, format_specification=''):
        pass

    def __round__(self, n):
        pass

Further Reading