Union changes in Python 3.14 crash mypy
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Crash Report
typeshed PR python/typeshed#13740, which adapts the changes to Union in Python 3.14 for typeshed crash mypy. (When running the tests with Python 3.14 or 3.15. Older Python versions are fine.)
The changes
Traceback
python tests/stubtest_stdlib.py
shell: /usr/bin/bash -e {0}
env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
FORCE_COLOR: 1
TERM: xterm-256color
pythonLocation: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64
PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/pkgconfig
Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64
Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64
Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib
/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/bin/python -m mypy.stubtest --check-typeshed --show-traceback --strict-type-check-only --custom-typeshed-dir . --allowlist stdlib/@tests/stubtest_allowlists/common.txt --allowlist stdlib/@tests/stubtest_allowlists/linux.txt --allowlist stdlib/@tests/stubtest_allowlists/py315.txt --allowlist stdlib/@tests/stubtest_allowlists/linux-py315.txt
/home/runner/work/typeshed/typeshed/stdlib/typing.pyi:1002: 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: 2.1.0
/home/runner/work/typeshed/typeshed/stdlib/typing.pyi:1002: note: use --pdb to drop into pdb
stdlib/typing_extensions.pyi:287: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [overload-overlap]
Traceback (most recent call last):
File "<frozen runpy>", line 201, in _run_module_as_main
File "<frozen runpy>", line 87, in _run_code
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/stubtest.py", line 2593, in <module>
sys.exit(main())
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/stubtest.py", line 2589, in main
return test_stubs(parse_options(sys.argv[1:]))
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/stubtest.py", line 2419, in test_stubs
modules = build_stubs(modules, options, find_submodules=not args.check_typeshed)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/stubtest.py", line 2215, in build_stubs
res = mypy.build.build(sources=sources, options=options)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 422, in build
result = build_inner(
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 537, in build_inner
graph = dispatch(sources, manager, stdout, connect_threads)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 4150, in dispatch
process_graph(graph, manager)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 4618, in process_graph
done, still_working, results = manager.wait_for_done(graph)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 1492, in wait_for_done
process_stale_scc(graph, next_scc, self)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 4792, in process_stale_scc
graph[id].type_check_first_pass()
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/build.py", line 3414, in type_check_first_pass
self.type_checker().check_first_pass(recurse_into_functions=recurse_into_functions)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checker.py", line 618, in check_first_pass
self.accept(d)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checker.py", line 765, in accept
stmt.accept(self)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/nodes.py", line 1907, in accept
return visitor.visit_assignment_stmt(self)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checker.py", line 3329, in visit_assignment_stmt
self.check_type_alias_rvalue(s)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checker.py", line 3370, in check_type_alias_rvalue
alias_type = self.expr_checker.accept(s.rvalue)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checkexpr.py", line 6176, in accept
typ = self.accept_maybe_cache(node, type_context=type_context)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checkexpr.py", line 6211, in accept_maybe_cache
typ = node.accept(self)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/nodes.py", line 2697, in accept
return visitor.visit_op_expr(self)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checkexpr.py", line 3559, in visit_op_expr
return self.accept(e.analyzed)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checkexpr.py", line 6178, in accept
typ = node.accept(self) # r-value type, when interpreted as a value expression
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/nodes.py", line 3420, in accept
return visitor.visit_type_alias_expr(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checkexpr.py", line 4967, in visit_type_alias_expr
return self.alias_type_in_runtime_context(alias.node, ctx=alias, alias_definition=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checkexpr.py", line 5024, in alias_type_in_runtime_context
return self.chk.named_generic_type("types.UnionType", item.items)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checker.py", line 7788, in named_generic_type
info = self.lookup_typeinfo(name)
File "/opt/hostedtoolcache/Python/3.15.0-beta.2/x64/lib/python3.15/site-packages/mypy/checker.py", line 7797, in lookup_typeinfo
assert isinstance(node, TypeInfo), node
~~~~~~~~~~^^^^^^^^^^^^^^^^
AssertionError: TypeAlias:723(
UnionType
Never
False)
Your Environment
Command run was: /opt/hostedtoolcache/Python/3.15.0-beta.2/x64/bin/python -m mypy.stubtest --check-typeshed --show-traceback --strict-type-check-only --custom-typeshed-dir . --allowlist stdlib/@tests/stubtest_allowlists/common.txt --allowlist stdlib/@tests/stubtest_allowlists/linux.txt --allowlist stdlib/@tests/stubtest_allowlists/py315.txt --allowlist stdlib/@tests/stubtest_allowlists/linux-py315.txt
- Mypy version used: 2.1.0
- Python version used: 3.14.5/3.15.0b2
- Operating system and version: Crashed on Ubuntu, Windows, MacOS
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con alias_type_in_runtime_context in mypy/checkexpr.py e il percorso lookup_typeinfo in mypy/checker.py, usando il traceback come punto di ingresso. Riproduci il problema con il comando fornito python -m mypy.stubtest su Python 3.14 o 3.15, quindi verifica che l’esecuzione di stubtest di typeshed termini senza l’errore interno.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 45/100