You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Erroneous "Self argument missing" error when decorators are used #19392
mypy sometimes erroneously emits a "Self argument missing" error on function definitions inside class definitons. See the example below.
If the function has no paramters, the error is "Method must have at least one argument.". Again, it does not matter what the decorator does to the function.
changed the title [-]Errnoeous "Self argument missing" error when decorators are used[/-][+]Erroneous "Self argument missing" error when decorators are used[/+]on Jul 7, 2025
Decorators that turn a callable method into a non-callable are exceptionally rare, mypy does not support this usecase. We expect any (decorated or not) method defined in class body to be just that - a method - and check accordingly.
Note that mypy understands that C.x is an integer, even in class body (playground), the only false positive is checking selftype too eagerly. You can safely put an ignore comment there, it should not affect further typechecking.
Activity
[-]Errnoeous "Self argument missing" error when decorators are used[/-][+]Erroneous "Self argument missing" error when decorators are used[/+]sterliakov commentedon Jul 11, 2025
Decorators that turn a callable method into a non-callable are exceptionally rare, mypy does not support this usecase. We expect any (decorated or not) method defined in class body to be just that - a method - and check accordingly.
Note that mypy understands that
C.xis an integer, even in class body (playground), the only false positive is checking selftype too eagerly. You can safely put an ignore comment there, it should not affect further typechecking.Merge branch 'master' into feature/pythongh-19392-decorator-selftypes
Merge branch 'master' into feature/pythongh-19392-decorator-selftypes
Move self argument checks to a later phase - after decorator applicat…