-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Incorrect type inference when using generics of "union" TypeVars #7913
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
And to be clear, this is irrespective of whether |
But changing |
I think I have the same issue here: import asyncio
async def f() -> None:
future: asyncio.Future[None] = asyncio.Future()
# error: Argument 1 to "gather" has incompatible type "Future[None]";
# expected "Union[Future[<nothing>], Generator[Any, None, <nothing>], Awaitable[<nothing>]]"
await asyncio.gather(future) |
@jonathanslenders that sounds like #8051. |
The inferred type for You can work around the issue by adding an explicit type annotation: ...
foo: CustomSet[Sequence[str]] = CustomSet()
foo.add(('a', 'b')) |
I may have ran into same issue here:
results in:
but
works. |
mypy 0.740 says:
error: Argument 1 to "add" of "CustomSet" has incompatible type "Tuple[str, str]"; expected "str"
There's seemingly nothing I can do to get mypy to handle this pattern correctly. If I try explicitly specifying the type of
foo
, it just complains that the assignment to it is incompatible.The text was updated successfully, but these errors were encountered: