Skip to content

Union changes in Python 3.14 crash mypy #21588

Description

@srittau

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: 1FORCE_COLOR: 1TERM: 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 mainreturn 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_passself.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_passself.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 acceptreturn 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_stmtself.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 acceptreturn 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_exprreturnself.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 acceptreturn 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_exprreturnself.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_contextreturnself.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_typeinfoassertisinstance(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions