-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Can't use Callable[..., T] | Callable[..., Awaitable[T]] as a function argument #14669
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
I don't know if this helps, but while trying to make a test for this I noticed that adding
|
For test cases, put the fixtures at the end (that may be why, though it may be a difference in typeshed vs fixtures in which case we should fix that) |
@A5rocks moving it at the end doesn't seem to change anything :) I can send a PR with the test, if that helps 😊 Also for now I changed my code to look like this: _RESOLVER_TYPE = Union[
Callable[..., T],
Callable[..., Coroutine[T, None, None]],
] which "fixed" my original problem :) |
Unfortunately it does not fix things if the signature with |
@patrick91 Sorry for the delay -- I've finally tried out the test... and it seemed to work? I stuck this at the bottom of my
And then I ran
Do you have specifics on what you're doing? (A link to a branch would work, or a PR as you suggested) |
I should have verified before sending this -- this is present in the commit before that!
I can't reproduce this working in mypy 0.991. This breakage doesn't seem recent. |
Sorry, just noticed your edit. This commit: fjarri/nucypher-async@25718f2 passes with
( |
@A5rocks sorry for the radio silence, I just tested this again and it seems to work with the latest version of mypy 😊 my final type looks like this:
|
Hmm, wacky. I meant to check the repository but completely forgot to. It's good that it's fixed now, nonetheless! EDIT: I forgot that your original example still fails and has done so since... a while. That should still be fixed, I suppose. |
Yes, I needed to keep the I'll leave this issue open then 😊 |
Code:
I was trying to define a callable that can be async or not and use a TypeVar as the return type, but it seem to be broken, here's the full example:
if I don't pass T it seem to work, no sure what is wrong, the error is:
Here's the playground url: https://mypy-play.net/?mypy=latest&python=3.11&gist=6d8ed4a4e55e0d6b2712eff23cd3e3b0
The text was updated successfully, but these errors were encountered: