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

function typing info is lost after applying functools.lru_cache #6668

Closed
raceychan opened this issue Dec 6, 2023 · 1 comment
Closed

function typing info is lost after applying functools.lru_cache #6668

raceychan opened this issue Dec 6, 2023 · 1 comment
Labels
as designed Not a bug, working as intended bug Something isn't working

Comments

@raceychan
Copy link

Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.

If you have a question about typing or a behavior that you’re seeing in Pyright (as opposed to a bug report or enhancement request), consider posting to the Pyright discussion forum.

Describe the bug
I read that [a wrong signature of a function or a class in the standard library] should be reported to typeshed
but the signature of functools.lru_cache seems to be doing fine, however,
when a function is decorated by functools.lru_cache, its typing info would be lost

Code or Screenshots
image

@lru_cache
def test(a: int) -> int:
    return a


test() # this woud not show any error

If your code relies on symbols that are imported from a third-party library, include the associated import statements and specify which versions of those libraries you have installed.

VS Code extension or command-line
Are you running pyright as a VS Code extension, a language server in another editor, integrated into Pylance, or the command-line tool? Which version?
vscode latest version

@raceychan raceychan added the bug Something isn't working label Dec 6, 2023
@erictraut
Copy link
Collaborator

Pyright is working as designed here. It's applying the type information supplied in the functools.pyi type stub.

If you would like to report a problem with the way lru_cache is defined in typeshed, please file a bug in the typeshed project. The current definition does not use a ParamSpec to retain the signature of the decorated function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
as designed Not a bug, working as intended bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants