Skip to content

decorator as class member raises "self-argument missing" #7778

Closed
@azrdev

Description

@azrdev

I have a legitimate case for member functions not requiring a self parameter, which fails with error: Self argument missing for a non-static method (or an invalid type for self) (mypy version 0.730, python 3.7.4). MWE:

import functools
from typing import Callable

class API:
    def _login_required(meth: Callable) -> Callable:
        @functools.wraps(meth)
        def check_login(self, *args, **kwargs):
            if not self.check_login():
                self.login()
            return meth(*args, **kwargs)
        return check_login

    @_login_required
    def version(self):
        pass

It is a member function of a class, to be used as decorator.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions