-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
0.902 crashes on tuple assignment #10653
Comments
Could you share the crashing code? |
Same issue here. /home/nico/.local/share/virtualenvs/blacklists_service--dBzAapY/lib/python3.9/site-packages/mode/services.py:684: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.902
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "mypy/checker.py", line 401, in accept
File "mypy/nodes.py", line 1073, in accept
File "mypy/checker.py", line 2013, in visit_assignment_stmt
File "mypy/checker.py", line 2051, in check_assignment
File "mypy/checker.py", line 2551, in check_assignment_to_multiple_lvalues
File "mypy/checker.py", line 2592, in check_multi_assignment
File "mypy/checker.py", line 2701, in check_multi_assignment_from_tuple
AssertionError:
/home/nico/.local/share/virtualenvs/blacklists_service--dBzAapY/lib/python3.9/site-packages/mode/services.py:684: : note: use --pdb to drop into pdb In this case as you can see, the error is when type-checking the package done, pending = await asyncio.wait(
futures.values(),
return_when=asyncio.FIRST_COMPLETED,
timeout=timeout,
loop=self.loop,
) |
- mypy 0.902 crashes, see also python/mypy#10653
73f3d73 is the first bad commit
This commit updates the typeshed for asyncio which triggers the internal crash |
Should be python/typeshed#5193 then. |
@TH3CHARLie Have you made any further progress with this crash? I can help if you can share a repro. I couldn't reproduce this (but I only spent a little time on this). |
I don't have a minimal repro right now, I can reproduce this on |
Here is a minimal(ish) reporo whittled down from the code in import asyncio
from typing import Awaitable, Set
async def wait_first(*coros: Awaitable) -> None:
futures = {coro: asyncio.ensure_future(coro) for coro in coros}
done: Set[asyncio.Future]
pending: Set[asyncio.Future]
done, pending = await asyncio.wait(futures.values()) stack trace
|
i remember last time i debug |
And here's a version with wait inlined from typeshed. Interestingly, it stops reproing when I try to inline import asyncio
from asyncio.futures import Future
from asyncio.tasks import Task
from typing import Any, Awaitable, Iterable, overload, Tuple, Set, TypeVar
_T = TypeVar("_T")
_FT = TypeVar("_FT", bound=Awaitable[Any])
@overload
def wait(fs: Iterable[_FT]) -> Future[Tuple[Set[_FT], Set[_FT]]]: ...
@overload
def wait(fs: Iterable[Awaitable[_T]]) -> Future[Tuple[Set[Task[_T]], Set[Task[_T]]]]: ...
def wait(fs: Any) -> Any:
raise Exception
async def wait_first(*coros: Awaitable) -> None:
futures = {coro: asyncio.ensure_future(coro) for coro in coros}
done: Set[asyncio.Future]
pending: Set[asyncio.Future]
done, pending = await wait(futures.values()) |
Here's a version with still fewer dependencies that doesn't depend on asyncio: from typing import Any, Awaitable, Iterable, overload, Tuple, List, TypeVar, Generic
T = TypeVar("T")
FT = TypeVar("FT", bound=Awaitable[Any])
class Future(Awaitable[T], Iterable[T]):
pass
class Task(Future[T]):
pass
@overload
def wait(fs: Iterable[FT]) -> Future[Tuple[List[FT], List[FT]]]: ...
@overload
def wait(fs: Iterable[Awaitable[T]]) -> Future[Tuple[List[Task[T]], List[Task[T]]]]: ...
def wait(fs: Any) -> Any:
pass
async def f() -> None:
done: Any
pending: Any
futures: Iterable[Task[Any]]
done, pending = await wait(futures) The crash is clearly a mypy bug, but the signature of |
When using lvalue context to re-infer call to an overloaded function, the inferred tuple type can switch to Any. Defensively accept this. It probably means that an Any component in argument types causes ambiguity. Fixes #10653.
Great work! Thanks! |
Crash Report
Mypy crashed after upgraded from 0.812 to 0.902
Traceback
To Reproduce
Your Environment
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: