Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy v1.10.0 errors out when functools wraps a method #17166

Open
davidbrochart opened this issue Apr 24, 2024 · 2 comments
Open

Mypy v1.10.0 errors out when functools wraps a method #17166

davidbrochart opened this issue Apr 24, 2024 · 2 comments
Labels
bug mypy got something wrong

Comments

@davidbrochart
Copy link

Bug Report

mypy v1.10.0 gives the following error, while it was working with v1.9.0:

test.py:13: error: Missing positional argument "self" in call to "__call__" of "_Wrapped"  [call-arg]

To Reproduce

# test.py

from functools import wraps

class Foo:
    def f(self):
        pass

class Bar:
    @wraps(Foo.f)
    def f(self):
        pass

bar = Bar()
bar.f()
mypy test.py

Expected Behavior

There should be no error.

@davidbrochart davidbrochart added the bug mypy got something wrong label Apr 24, 2024
@AlexWaygood
Copy link
Member

almost certainly due to #16942

@Hnasar
Copy link
Contributor

Hnasar commented Apr 24, 2024

I also hit this in a few places. Here's the relevant upstream bug python/typeshed#10653

Workaround I used:

from typing import TYPE_CHECKING

class Bar:
    def f(self):
        pass

    if not TYPE_CHECKING:
        f = wraps(Foo.f)(f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

3 participants