-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Crash Report
Example from #16662 is no longer a bug since 1.18.1 - 1.17.1 produces a wrong error, and 1.18.1 up to current master dies hard with a traceback.
Bisects to #186515f6 (#19619), cc @hauntsaninja
Traceback
d.py:22: 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.19.0+dev.583c5f7efe5b851c140dbd2458619182137261bc
Traceback (most recent call last):
File "/tmp/tmp.d9375bltfC/.venv/bin/mypy", line 10, in <module>
sys.exit(console_entry())
File "/home/stas/Documents/Work/mypy/mypy/__main__.py", line 15, in console_entry
main()
File "/home/stas/Documents/Work/mypy/mypy/main.py", line 127, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/home/stas/Documents/Work/mypy/mypy/main.py", line 211, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 222, in build
result = _build(
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 301, in _build
graph = dispatch(sources, manager, stdout)
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 2994, in dispatch
process_graph(graph, manager)
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 3385, in process_graph
done, still_working = manager.wait_for_done(graph)
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 976, in wait_for_done
process_stale_scc(graph, next_scc, self)
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 3523, in process_stale_scc
graph[id].type_check_first_pass()
File "/home/stas/Documents/Work/mypy/mypy/build.py", line 2385, in type_check_first_pass
self.type_checker().check_first_pass()
File "/home/stas/Documents/Work/mypy/mypy/checker.py", line 524, in check_first_pass
self.accept(d)
File "/home/stas/Documents/Work/mypy/mypy/checker.py", line 635, in accept
stmt.accept(self)
File "/home/stas/Documents/Work/mypy/mypy/nodes.py", line 1562, in accept
return visitor.visit_expression_stmt(self)
File "/home/stas/Documents/Work/mypy/mypy/checker.py", line 4845, in visit_expression_stmt
expr_type = self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 6022, in accept
typ = self.visit_call_expr(node, allow_none_return=True)
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 495, in visit_call_expr
return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 632, in visit_call_expr_inner
ret_type = self.check_call_expr_with_callee_type(
callee_type, e, fullname, object_type, member
)
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 1483, in check_call_expr_with_callee_type
ret_type, callee_type = self.check_call(
~~~~~~~~~~~~~~~^
callee_type,
^^^^^^^^^^^^
...<6 lines>...
object_type=object_type,
^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 1576, in check_call
return self.check_callable_call(
~~~~~~~~~~~~~~~~~~~~~~~~^
callee,
^^^^^^^
...<6 lines>...
object_type,
^^^^^^^^^^^^
)
^
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 1755, in check_callable_call
callee = self.infer_function_type_arguments(
callee, args, arg_kinds, arg_names, formal_to_actual, need_refresh, context
)
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 2106, in infer_function_type_arguments
(callee_type, inferred_args) = self.infer_function_type_arguments_pass2(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
callee_type,
^^^^^^^^^^^^
...<6 lines>...
context,
^^^^^^^^
)
^
File "/home/stas/Documents/Work/mypy/mypy/checkexpr.py", line 2246, in infer_function_type_arguments_pass2
inferred_args, _ = infer_function_type_arguments(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
callee_type,
^^^^^^^^^^^^
...<4 lines>...
context=self.argument_infer_context(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/stas/Documents/Work/mypy/mypy/infer.py", line 57, in infer_function_type_arguments
constraints = infer_constraints_for_callable(
callee_type, arg_types, arg_kinds, arg_names, formal_to_actual, context
)
File "/home/stas/Documents/Work/mypy/mypy/constraints.py", line 252, in infer_constraints_for_callable
c = infer_constraints(callee.arg_types[i], actual_type, SUPERTYPE_OF)
File "/home/stas/Documents/Work/mypy/mypy/constraints.py", line 320, in infer_constraints
return _infer_constraints(template, actual, direction, skip_neg_op)
File "/home/stas/Documents/Work/mypy/mypy/constraints.py", line 428, in _infer_constraints
return template.accept(ConstraintBuilderVisitor(actual, direction, skip_neg_op))
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/types.py", line 2287, in accept
return visitor.visit_callable_type(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/constraints.py", line 1153, in visit_callable_type
infer_callable_arguments_constraints(template, cactual, self.direction)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/constraints.py", line 1654, in infer_callable_arguments_constraints
left_arg = mypy.typeops.callable_corresponding_argument(left, right_arg)
File "/home/stas/Documents/Work/mypy/mypy/typeops.py", line 534, in callable_corresponding_argument
by_name.name, by_pos.pos, meet_types(by_name.typ, by_pos.typ), False
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/meet.py", line 113, in meet_types
return t.accept(TypeMeetVisitor(s))
~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/types.py", line 1210, in accept
return visitor.visit_unpack_type(self)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/stas/Documents/Work/mypy/mypy/meet.py", line 833, in visit_unpack_type
raise NotImplementedError
NotImplementedError:
d.py:17: : note: use --pdb to drop into pdbTo Reproduce
from typing import Callable, ParamSpec, TypeVar, TypeVarTuple, Unpack
P = ParamSpec("P")
T = TypeVar("T")
Ts = TypeVarTuple("Ts")
def call(func: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
return func(*args, **kwargs)
def run(func: Callable[[Unpack[Ts]], T], *args: Unpack[Ts], some_kwarg: str = "asdf") -> T:
raise NotImplementedError
def foo() -> str:
raise NotImplementedError
call(run, foo, some_kwarg="a")Your Environment
- Mypy version used: 1.18.2 and master (#583c5f7e)
- Mypy command-line flags:
--show-traceback - Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.12, 3.13
- Operating system and version:
Linux pc 6.14.0-33-generic #33~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 19 17:02:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux