-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Crash Report
Mypy crashes with NotImplementedError
when defining a dataclass parametrized by two generics where one of them is a TypeVarTuple.
Traceback
version: 1.18.0+dev.07d4a1bf9c73f39d6c05d6665c1fafc8f12c3e77
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/mypy-test/mypy/mypy/__main__.py", line 37, in <module>
console_entry()
File "/mypy-test/mypy/mypy/__main__.py", line 15, in console_entry
main()
File "/mypy-test/mypy/mypy/main.py", line 127, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/mypy-test/mypy/mypy/main.py", line 211, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/mypy-test/mypy/mypy/build.py", line 191, in build
result = _build(
File "/mypy-test/mypy/mypy/build.py", line 267, in _build
graph = dispatch(sources, manager, stdout)
File "/mypy-test/mypy/mypy/build.py", line 2939, in dispatch
process_graph(graph, manager)
File "/mypy-test/mypy/mypy/build.py", line 3337, in process_graph
process_stale_scc(graph, scc, manager)
File "/mypy-test/mypy/mypy/build.py", line 3438, in process_stale_scc
graph[id].type_check_first_pass()
File "/mypy-test/mypy/mypy/build.py", line 2311, in type_check_first_pass
self.type_checker().check_first_pass()
File "/mypy-test/mypy/mypy/checker.py", line 483, in check_first_pass
self.accept(d)
File "/mypy-test/mypy/mypy/checker.py", line 594, in accept
stmt.accept(self)
~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/nodes.py", line 1249, in accept
return visitor.visit_class_def(self)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/checker.py", line 2658, in visit_class_def
infer_class_variances(defn.info)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/mypy-test/mypy/mypy/subtypes.py", line 2266, in infer_class_variances
if not infer_variance(info, i):
~~~~~~~~~~~~~~^^^^^^^^^
File "/mypy-test/mypy/mypy/subtypes.py", line 2215, in infer_variance
typ = find_member(member, self_type, self_type)
File "/mypy-test/mypy/mypy/subtypes.py", line 1352, in find_member
return analyze_instance_member_access(name, itype, mx, info)
File "/mypy-test/mypy/mypy/checkmember.py", line 379, in analyze_instance_member_access
member_type = expand_type_by_instance(signature, typ)
File "/mypy-test/mypy/mypy/expandtype.py", line 115, in expand_type_by_instance
return expand_type(typ, variables)
File "/mypy-test/mypy/mypy/expandtype.py", line 70, in expand_type
return typ.accept(ExpandTypeVisitor(env))
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/mypy-test/mypy/mypy/types.py", line 2030, in accept
return visitor.visit_callable_type(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/expandtype.py", line 421, in visit_callable_type
ret_type=t.ret_type.accept(self),
~~~~~~~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/types.py", line 1490, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/expandtype.py", line 216, in visit_instance
args = self.expand_type_tuple_with_unpack(t.args)
File "/mypy-test/mypy/mypy/expandtype.py", line 456, in expand_type_tuple_with_unpack
items.append(item.accept(self))
~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/types.py", line 901, in accept
return visitor.visit_type_var_tuple(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/mypy-test/mypy/mypy/expandtype.py", line 298, in visit_type_var_tuple
raise NotImplementedError
NotImplementedError:
../../mypy_debug.py:6: : note: use --pdb to drop into pdb
To Reproduce
from collections.abc import Callable
from dataclasses import dataclass
@dataclass
class Test[*Ts, R]:
a: Callable[[*Ts], R]
Your Environment
- Mypy version used: 1.17.1 and master - 1.18.0+dev.07d4a1bf9c73f39d6c05d6665c1fafc8f12c3e77
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files): python_version = 3.13 - Python version used: 3.13.3
- Operating system and version: Red Hat Enterprise Linux 9.5 (Plow)