-
-
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
Internal error with an alias type that is a callable with an unpacked tuple as args #16533
Labels
crash
topic-pep-646
PEP 646 (TypeVarTuple, Unpack)
topic-type-alias
TypeAlias and other type alias issues
Comments
AlexWaygood
added
crash
topic-pep-646
PEP 646 (TypeVarTuple, Unpack)
topic-type-alias
TypeAlias and other type alias issues
and removed
bug
mypy got something wrong
labels
Nov 21, 2023
Here's the traceback using uncompiled mypy from the version: 1.8.0+dev.242ad2ac4dec105fbed37c177d4cff5944a00f1d
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\alexw\coding\mypy\venv\Scripts\mypy.exe\__main__.py", line 7, in <module>
sys.exit(console_entry())
File "C:\Users\alexw\coding\mypy\mypy\__main__.py", line 15, in console_entry
main()
File "C:\Users\alexw\coding\mypy\mypy\main.py", line 100, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "C:\Users\alexw\coding\mypy\mypy\main.py", line 182, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 191, in build
result = _build(
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 265, in _build
graph = dispatch(sources, manager, stdout)
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 2943, in dispatch
process_graph(graph, manager)
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 3341, in process_graph
process_stale_scc(graph, scc, manager)
File "C:\Users\alexw\coding\mypy\mypy\build.py", line 3436, in process_stale_scc
mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
File "C:\Users\alexw\coding\mypy\mypy\semanal_main.py", line 94, in semantic_analysis_for_scc
process_functions(graph, scc, patches)
File "C:\Users\alexw\coding\mypy\mypy\semanal_main.py", line 252, in process_functions
process_top_level_function(
File "C:\Users\alexw\coding\mypy\mypy\semanal_main.py", line 291, in process_top_level_function
deferred, incomplete, progress = semantic_analyze_target(
File "C:\Users\alexw\coding\mypy\mypy\semanal_main.py", line 349, in semantic_analyze_target
analyzer.refresh_partial(
File "C:\Users\alexw\coding\mypy\mypy\semanal.py", line 600, in refresh_partial
self.accept(node)
File "C:\Users\alexw\coding\mypy\mypy\semanal.py", line 6538, in accept
node.accept(self)
File "C:\Users\alexw\coding\mypy\mypy\nodes.py", line 787, in accept
return visitor.visit_func_def(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\semanal.py", line 833, in visit_func_def
self.analyze_func_def(defn)
File "C:\Users\alexw\coding\mypy\mypy\semanal.py", line 867, in analyze_func_def
if self.found_incomplete_ref(tag) or has_placeholder(result):
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\semanal_shared.py", line 373, in has_placeholder
return typ.accept(HasPlaceholders())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\types.py", line 1970, in accept
return visitor.visit_callable_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\type_visitor.py", line 505, in visit_callable_type
args = self.query_types(t.arg_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\type_visitor.py", line 557, in query_types
return any(t.accept(self) for t in types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\type_visitor.py", line 557, in <genexpr>
return any(t.accept(self) for t in types)
^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\types.py", line 401, in accept
return visitor.visit_type_alias_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\type_visitor.py", line 550, in visit_type_alias_type
return get_proper_type(t).accept(self)
^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\types.py", line 3078, in get_proper_type
typ = typ._expand_once()
^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\types.py", line 343, in _expand_once
new_tp = self.alias.target.accept(InstantiateAliasVisitor(mapping))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\types.py", line 1970, in accept
return visitor.visit_callable_type(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\expandtype.py", line 369, in visit_callable_type
arg_types = self.interpolate_args_for_unpack(t, var_arg.typ)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\mypy\mypy\expandtype.py", line 318, in interpolate_args_for_unpack
assert isinstance(var_arg_type, TypeVarTupleType)
AssertionError: It looks like |
JukkaL
pushed a commit
that referenced
this issue
Dec 12, 2023
wesleywright
pushed a commit
that referenced
this issue
Dec 12, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
crash
topic-pep-646
PEP 646 (TypeVarTuple, Unpack)
topic-type-alias
TypeAlias and other type alias issues
Bug Report
Mypy crashes (errors) when using an aliased
Callable
with an unpackedTuple
within the arguments part. The definition throws no errors and using the type without the use of an alias is also working fine.mypy version: 1.7.0
python version: 3.11.2
To Reproduce
This is the smallest reproduction I could come up with. The error occours with the definition of
f2
where the type alias_CallableValue
is used.(Playground)
Expected Behavior
I would expect mypy to not have an internal error and instead produce a success result.
Actual Behavior
Mypy has an internal error.
Output with my projects environment (VSCode, Python 3.11.2, mypy 1.7.0 (compiled: yes)):
Playground gist output (Python 3.11 and mypy 1.7.0)
Your Environment
-no-color-output --no-error-summary --show-absolute-path --show-column-numbers --show-error-codes --no-pretty --show-traceback --show-error-end c:\Users\[PROJECT_PATH]\.vscode\mypytest.py
mypy.ini
(and other config files):(It's reproducable on the mypy playground, please see the "Playground"-link at the bottom of the "To Reproduce"-section.)
The text was updated successfully, but these errors were encountered: