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

Add IDE friendly type annotation for jit #9932

Closed
YouJiacheng opened this issue Mar 17, 2022 · 4 comments · May be fixed by #9999
Closed

Add IDE friendly type annotation for jit #9932

YouJiacheng opened this issue Mar 17, 2022 · 4 comments · May be fixed by #9999
Labels
enhancement New feature or request

Comments

@YouJiacheng
Copy link
Contributor

see #9917

@froystig
Copy link
Member

Did #9950 take care of this?

@YouJiacheng
Copy link
Contributor Author

@froystig Thanks for your reply! #9950 is awesome, but it didn't take care of function's signature. Can you make a generic-type protocol?

@YouJiacheng
Copy link
Contributor Author

YouJiacheng commented Mar 23, 2022

@froystig
See:

from typing import TypeVar, Callable
from typing_extensions import ParamSpec, Protocol

T = TypeVar('T')
P = ParamSpec('P')

class Wrapped(Protocol[P, T]):
  def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
    """Executes the wrapped function, lowering and compiling as needed."""

def jit(f: Callable[P, T]) -> Wrapped[P, T]:
    pass

def f(x: float, y: float):
    return x + y

May I create a PR for it?

@YouJiacheng
Copy link
Contributor Author

#10311 Instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants