Skip to content

Functionality to copy and enforce signatures of function declarations #257

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

Open
KotlinIsland opened this issue Mar 25, 2022 · 0 comments
Open
Labels

Comments

@KotlinIsland
Copy link
Owner

KotlinIsland commented Mar 25, 2022

def foo(a: int) -> str: ...

@func_type[foo]
def bar():  # missing parameter 'a'
    return 1   # expected return str, found int
    
# OR
def bar(*args: ParamSpec[foo].args, **kwargs: ParamSpec[foo].kwargs) -> ???[foo].return:
    return foo(*args, **kwargs)

A member on the design team had this to say:

class Callable[**P, R]:
    type args = P.args
    type kwargs:= P.kwargs
    type return_type = R
    
def bar(*args: foo.args, **kwargs: foo.kwargs) -> foo.return_type: ...
# and a runtime version like:
def bar(*args: Callable[foo].args, **kwargs: Callable[foo].kwargs) -> Callable[foo].return_type: ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant