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

Ability to force pylance to treat wrapped functions as functions as opposed to variables #5856

Closed
jabbera opened this issue May 7, 2024 · 2 comments
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@jabbera
Copy link

jabbera commented May 7, 2024

With the following code pylance recognizes wrapped_function_definition as a variable/constant. I'd love a way to force pylance to treat this as a function. (Unless there is another way I should be using to provide both a wrapped and unwrapped implementation of the same function without having to keep the parameter list/typehints up to date?) See the screenshot, wrapped_function_definition is blue and listed as a constant as opposed to yellow and listed as a function.

image
from collections.abc import Callable
from typing import Final, ParamSpec, TypeVar

T = TypeVar("T")
P = ParamSpec("P")


def wrap_function(func: Callable[P, T]) -> Callable[P, T]:
    def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
        return func(*args, **kwargs)

    return wrapper


def function_to_wrap(i: int) -> int:
    return i


wrapped_function_definition: Final = wrap_function(function_to_wrap)
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label May 7, 2024
@debonte
Copy link
Contributor

debonte commented May 7, 2024

This is a duplicate of #5785. You may want to up-vote the issue that spun out of that one -- #5841.

@debonte debonte closed this as completed May 7, 2024
@debonte debonte added duplicate This issue or pull request already exists and removed needs repro Issue has not been reproduced yet labels May 7, 2024
@jabbera
Copy link
Author

jabbera commented May 7, 2024

Thanks! I tried to search it before but was unable to locate those issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants