-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Crash Report
Mypy crashes with INTERNAL ERROR when passing typed unpacked kwargs to asyncio.to_thread. Something with asyncio.to_thread signature causes the crash.
Traceback
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: 1.8.0
Traceback (most recent call last):
File "mypy/checkexpr.py", line 5727, in accept
File "mypy/nodes.py", line 1904, in accept
File "mypy/checkexpr.py", line 473, in visit_call_expr
File "mypy/checkexpr.py", line 602, in visit_call_expr_inner
File "mypy/checkexpr.py", line 1440, in check_call_expr_with_callee_type
File "mypy/checkexpr.py", line 1535, in check_call
File "mypy/checkexpr.py", line 1720, in check_callable_call
File "mypy/checkexpr.py", line 2045, in infer_function_type_arguments
File "mypy/infer.py", line 56, in infer_function_type_arguments
File "mypy/constraints.py", line 236, in infer_constraints_for_callable
File "mypy/argmap.py", line 248, in expand_actual_type
KeyError: 'pop from an empty set'To Reproduce
Following code snipped causes the crash.
import asyncio
from typing import TypedDict, Unpack
class Foo(TypedDict):
a: int
def bar(a: int) -> None: ...
async def foo(**kwargs: Unpack[Foo]) -> None:
await asyncio.to_thread(bar, **kwargs)This snippet has no issues.
async def bar(int a) -> None: ...
async def foo(**kwargs: Unpack[Foo]) -> None:
await bar(**kwargs)Your Environment
No mypy.ini settings.
python --version
Python 3.12.2
mypy --version
mypy 1.8.0 (compiled: yes)