Skip to content

False-positive for functools.cache decorated methods #2578

@vemel

Description

@vemel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions