-
Notifications
You must be signed in to change notification settings - Fork 7
An Infer
annotation
#298
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
Comments
What contexts can this be used in? Is that just for the return type of methods / functions that contain a Should it be able to be combined with other types, such as Should it be able to infer def foo(a) -> Infer:
return a being the same as from typing import TypeVar
T = TypeVar("T")
def foo(a: T) -> T:
return a or would that only work if And is inferring the return type it is a |
it's not the same as using a def foo() -> T:
result: int = 2
return result
bar: Literal[1] = foo() which is why you get this error:
|
In my example, the parameter |
def foo(a) -> Infer:
return a Potentially something like this could be accepted where the type checker figures out that |
could this also be used in conditional types like in typescript? type Foo[T] = R if T extends Callable[[], Infer[R]] else Never |
Useful to resolve
default_return
vs infer return type.The text was updated successfully, but these errors were encountered: