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

False-positive for functools.cache decorated methods #2578

Closed
vemel opened this issue Nov 17, 2021 · 3 comments
Closed

False-positive for functools.cache decorated methods #2578

vemel opened this issue Nov 17, 2021 · 3 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@vemel
Copy link
Contributor

vemel commented Nov 17, 2021

Describe the bug

pyright marks methods wrapped with functools.cache/functools.lru_cache decorator calls as error: Argument missing for parameter "self". Functions are not affected, only methods.

This bug was introduced in 1.1.187. 1.1.186 is not affected.

To Reproduce

Run pyright on this sample:

from functools import cache


class A:
    @cache
    def has_cache(self) -> None:
        print(self)

    def no_cache(self) -> None:
        print(self)


a = A()
a.has_cache()  #  error: Argument missing for parameter "self"
a.has_cache(a)  # no typing errors, but obviously a RuntimeError
a.no_cache()  # all good

Expected behavior
No error

VS Code extension or command-line
Command line with pyright 1.1.187.

@erictraut
Copy link
Collaborator

Thanks for creating the issue. Based on my understanding of PEP 612, pyright's current behavior is correct.

I've asked for input from the PEP 612 authors and the broader Python typing community here.

@erictraut
Copy link
Collaborator

The typeshed maintainers have decided to revert the change to functools.pyi for now. I've incorporated the updated stubs, so this problem will be fixed in the next release of pyright.

@erictraut erictraut added addressed in next version Issue is fixed and will appear in next published version bug Something isn't working and removed needs decision labels Nov 24, 2021
@erictraut
Copy link
Collaborator

This is included in pyright 1.1.190, which I just published. It will also be included in the next release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants