You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to type a function that takes in a function, and a value, and returns the arguments of the function. For example, this is how it would look supporting two argument functions:
This works great when the callable I pass in is not generic, like this:
defhi(a: int, b: str) ->str:
...
reveal_type(extract_args(hi, "return"))
# Revealed type is 'Tuple[builtins.int*, builtins.str*]'
However, if I try to make the function generic, it doesn't seem to work:
defhi_generic(a: int, b: X) ->X:
...
reveal_type(extract_args(hi_generic, "return"))
# Argument 1 to "extract_args" has incompatible type "Callable[[int, X], X]"; expected "Callable[[int, X], str]"# Revealed type is 'Tuple[builtins.int*, X`-1]'
I would expect it to infer fn has type Callable[[int, str], str] since I am passing in the return value of type str so the second arg also has to be a str.
I am trying to type a function that takes in a function, and a value, and returns the arguments of the function. For example, this is how it would look supporting two argument functions:
This works great when the callable I pass in is not generic, like this:
However, if I try to make the function generic, it doesn't seem to work:
I would expect it to infer
fn
has typeCallable[[int, str], str]
since I am passing in the return value of typestr
so the second arg also has to be astr
.This might be the same issue as #3193.
If anyone has a work around for how I could get a function like this to type, they would be much appreciated!
The text was updated successfully, but these errors were encountered: