Skip to content

[1.19 regression] mypy crashes over asyncua #20327

@owillebo

Description

@owillebo

mypy as of version 1.19.0 crashes over asyncua under certain circumstances.

RMDIR /S /Q .venv
RMDIR /S /Q .mypy_cache
ERASE *.py
py -3.14-64 -m venv .venv
CALL .venv\Scripts\activate
@ECHO ON
python -m pip install -U pip
python -m pip install asyncua
python --version
REM ~ Add missing py.typed to asyncua package.
ECHO. > .venv\Lib\site-packages\asyncua\py.typed
REM ~ Create test code.
ECHO import asyncua.ua > test_1.py
ECHO import asyncua.ua > test_2.py

REM ~ Install previous mypy.
python -m pip install mypy==1.18.2
python -m pip freeze
REM ~ Run mypy on the first file which runs fine.
mypy test_1.py
REM ~ Run mypy on the second file which runs fine.
mypy test_2.py

REM ~ Clear the mypy cache.
RMDIR /S /Q .mypy_cache

REM ~ Install latest mypy.
python -m pip install -U mypy
python -m pip freeze
REM ~ Run mypy on the first file which runs fine.
mypy test_1.py
REM ~ Run mypy on the second file. mypy crashes.
mypy test_2.py
REM ~ Run mypy on the first file which still runs fine.
mypy test_1.py
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:\Temp\mypy\.venv\Scripts\mypy.exe\__main__.py", line 6, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "C:\Temp\mypy\.venv\Lib\site-packages\mypy\__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy\main.py", line 127, in main
  File "mypy\main.py", line 211, in run_build
  File "mypy\build.py", line 215, in build
  File "mypy\build.py", line 294, in _build
  File "mypy\build.py", line 2945, in dispatch
  File "mypy\build.py", line 3336, in process_graph
  File "mypy\build.py", line 918, in wait_for_done
  File "mypy\build.py", line 3444, in process_stale_scc
  File "mypy\build.py", line 3404, in process_fresh_modules
  File "mypy\build.py", line 2128, in fix_cross_refs
  File "mypy\fixup.py", line 53, in fixup_module
  File "mypy\fixup.py", line 150, in visit_symbol_table
AssertionError: ('asyncua.ua.Union-redefinition', 'asyncua.ua.uaprotocol_auto.Union')
C:\Temp\mypy>RMDIR /S /Q .venv 
The system cannot find the file specified.

C:\Temp\mypy>RMDIR /S /Q .mypy_cache 
The system cannot find the file specified.

C:\Temp\mypy>ERASE *.py 
Could Not Find C:\Temp\mypy\*.py

C:\Temp\mypy>py -3.14-64 -m venv .venv 

C:\Temp\mypy>CALL .venv\Scripts\activate 

(.venv) C:\Temp\mypy>python -m pip install -U pip 
Requirement already satisfied: pip in c:\temp\mypy\.venv\lib\site-packages (25.2)
Collecting pip
  Using cached pip-25.3-py3-none-any.whl.metadata (4.7 kB)
Using cached pip-25.3-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 25.2
    Uninstalling pip-25.2:
      Successfully uninstalled pip-25.2
Successfully installed pip-25.3

(.venv) C:\Temp\mypy>python -m pip install asyncua 
Collecting asyncua
  Using cached asyncua-1.1.8-py3-none-any.whl.metadata (9.6 kB)
Collecting aiofiles (from asyncua)
  Using cached aiofiles-25.1.0-py3-none-any.whl.metadata (6.3 kB)
Collecting aiosqlite (from asyncua)
  Using cached aiosqlite-0.21.0-py3-none-any.whl.metadata (4.3 kB)
Collecting cryptography>42.0.0 (from asyncua)
  Using cached cryptography-46.0.3-cp311-abi3-win_amd64.whl.metadata (5.7 kB)
Collecting pyopenssl>23.2.0 (from asyncua)
  Using cached pyopenssl-25.3.0-py3-none-any.whl.metadata (17 kB)
Collecting python-dateutil (from asyncua)
  Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz (from asyncua)
  Using cached pytz-2025.2-py2.py3-none-any.whl.metadata (22 kB)
Collecting sortedcontainers (from asyncua)
  Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl.metadata (10 kB)
Collecting typing-extensions (from asyncua)
  Using cached typing_extensions-4.15.0-py3-none-any.whl.metadata (3.3 kB)
Collecting cffi>=2.0.0 (from cryptography>42.0.0->asyncua)
  Using cached cffi-2.0.0-cp314-cp314-win_amd64.whl.metadata (2.6 kB)
Collecting pycparser (from cffi>=2.0.0->cryptography>42.0.0->asyncua)
  Using cached pycparser-2.23-py3-none-any.whl.metadata (993 bytes)
Collecting six>=1.5 (from python-dateutil->asyncua)
  Using cached six-1.17.0-py2.py3-none-any.whl.metadata (1.7 kB)
Using cached asyncua-1.1.8-py3-none-any.whl (1.1 MB)
Using cached cryptography-46.0.3-cp311-abi3-win_amd64.whl (3.5 MB)
Using cached cffi-2.0.0-cp314-cp314-win_amd64.whl (185 kB)
Using cached pyopenssl-25.3.0-py3-none-any.whl (57 kB)
Using cached aiofiles-25.1.0-py3-none-any.whl (14 kB)
Using cached aiosqlite-0.21.0-py3-none-any.whl (15 kB)
Using cached typing_extensions-4.15.0-py3-none-any.whl (44 kB)
Using cached pycparser-2.23-py3-none-any.whl (118 kB)
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Using cached six-1.17.0-py2.py3-none-any.whl (11 kB)
Using cached pytz-2025.2-py2.py3-none-any.whl (509 kB)
Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Installing collected packages: sortedcontainers, pytz, typing-extensions, six, pycparser, aiofiles, python-dateutil, cffi, aiosqlite, cryptography, pyopenssl, asyncua

Successfully installed aiofiles-25.1.0 aiosqlite-0.21.0 asyncua-1.1.8 cffi-2.0.0 cryptography-46.0.3 pycparser-2.23 pyopenssl-25.3.0 python-dateutil-2.9.0.post0 pytz-2025.2 six-1.17.0 sortedcontainers-2.4.0 typing-extensions-4.15.0

(.venv) C:\Temp\mypy>python --version 
Python 3.14.0

(.venv) C:\Temp\mypy>REM ~ Add missing py.typed to asyncua package. 

(.venv) C:\Temp\mypy>ECHO.  1>.venv\Lib\site-packages\asyncua\py.typed 

(.venv) C:\Temp\mypy>REM ~ Create test code. 

(.venv) C:\Temp\mypy>ECHO import asyncua.ua  1>test_1.py 

(.venv) C:\Temp\mypy>ECHO import asyncua.ua  1>test_2.py 

(.venv) C:\Temp\mypy>REM ~ Install previous mypy. 

(.venv) C:\Temp\mypy>python -m pip install mypy==1.18.2 
Collecting mypy==1.18.2
  Using cached mypy-1.18.2-cp314-cp314-win_amd64.whl.metadata (2.2 kB)
Requirement already satisfied: typing_extensions>=4.6.0 in c:\temp\mypy\.venv\lib\site-packages (from mypy==1.18.2) (4.15.0)
Collecting mypy_extensions>=1.0.0 (from mypy==1.18.2)
  Using cached mypy_extensions-1.1.0-py3-none-any.whl.metadata (1.1 kB)
Collecting pathspec>=0.9.0 (from mypy==1.18.2)
  Using cached pathspec-0.12.1-py3-none-any.whl.metadata (21 kB)
Using cached mypy-1.18.2-cp314-cp314-win_amd64.whl (10.0 MB)
Using cached mypy_extensions-1.1.0-py3-none-any.whl (5.0 kB)
Using cached pathspec-0.12.1-py3-none-any.whl (31 kB)
Installing collected packages: pathspec, mypy_extensions, mypy

Successfully installed mypy-1.18.2 mypy_extensions-1.1.0 pathspec-0.12.1

(.venv) C:\Temp\mypy>python -m pip freeze 
aiofiles==25.1.0
aiosqlite==0.21.0
asyncua==1.1.8
cffi==2.0.0
cryptography==46.0.3
mypy==1.18.2
mypy_extensions==1.1.0
pathspec==0.12.1
pycparser==2.23
pyOpenSSL==25.3.0
python-dateutil==2.9.0.post0
pytz==2025.2
six==1.17.0
sortedcontainers==2.4.0
typing_extensions==4.15.0

(.venv) C:\Temp\mypy>REM ~ Run mypy on the first file which runs fine. 

(.venv) C:\Temp\mypy>mypy test_1.py 
Success: no issues found in 1 source file

(.venv) C:\Temp\mypy>REM ~ Run mypy on the second file which runs fine. 

(.venv) C:\Temp\mypy>mypy test_2.py 
Success: no issues found in 1 source file

(.venv) C:\Temp\mypy>REM ~ Clear the mypy cache. 

(.venv) C:\Temp\mypy>RMDIR /S /Q .mypy_cache 

(.venv) C:\Temp\mypy>REM ~ Install latest mypy. 

(.venv) C:\Temp\mypy>python -m pip install -U mypy 
Requirement already satisfied: mypy in c:\temp\mypy\.venv\lib\site-packages (1.18.2)
Collecting mypy
  Using cached mypy-1.19.0-cp314-cp314-win_amd64.whl.metadata (2.2 kB)
Requirement already satisfied: typing_extensions>=4.6.0 in c:\temp\mypy\.venv\lib\site-packages (from mypy) (4.15.0)
Requirement already satisfied: mypy_extensions>=1.0.0 in c:\temp\mypy\.venv\lib\site-packages (from mypy) (1.1.0)
Requirement already satisfied: pathspec>=0.9.0 in c:\temp\mypy\.venv\lib\site-packages (from mypy) (0.12.1)
Collecting librt>=0.6.2 (from mypy)
  Using cached librt-0.6.2-cp314-cp314-win_amd64.whl.metadata (1.4 kB)
Using cached mypy-1.19.0-cp314-cp314-win_amd64.whl (10.3 MB)
Using cached librt-0.6.2-cp314-cp314-win_amd64.whl (20 kB)
Installing collected packages: librt, mypy
  Attempting uninstall: mypy
    Found existing installation: mypy 1.18.2
    Uninstalling mypy-1.18.2:
      Successfully uninstalled mypy-1.18.2

Successfully installed librt-0.6.2 mypy-1.19.0

(.venv) C:\Temp\mypy>python -m pip freeze 
aiofiles==25.1.0
aiosqlite==0.21.0
asyncua==1.1.8
cffi==2.0.0
cryptography==46.0.3
librt==0.6.2
mypy==1.19.0
mypy_extensions==1.1.0
pathspec==0.12.1
pycparser==2.23
pyOpenSSL==25.3.0
python-dateutil==2.9.0.post0
pytz==2025.2
six==1.17.0
sortedcontainers==2.4.0
typing_extensions==4.15.0

(.venv) C:\Temp\mypy>REM ~ Run mypy on the first file which runs fine. 

(.venv) C:\Temp\mypy>mypy test_1.py 
Success: no issues found in 1 source file

(.venv) C:\Temp\mypy>REM ~ Run mypy on the second file. mypy crashes. 

(.venv) C:\Temp\mypy>mypy test_2.py 
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:\Temp\mypy\.venv\Scripts\mypy.exe\__main__.py", line 6, in <module>
    sys.exit(console_entry())
             ~~~~~~~~~~~~~^^
  File "C:\Temp\mypy\.venv\Lib\site-packages\mypy\__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "mypy\main.py", line 127, in main
  File "mypy\main.py", line 211, in run_build
  File "mypy\build.py", line 215, in build
  File "mypy\build.py", line 294, in _build
  File "mypy\build.py", line 2945, in dispatch
  File "mypy\build.py", line 3336, in process_graph
  File "mypy\build.py", line 918, in wait_for_done
  File "mypy\build.py", line 3444, in process_stale_scc
  File "mypy\build.py", line 3404, in process_fresh_modules
  File "mypy\build.py", line 2128, in fix_cross_refs
  File "mypy\fixup.py", line 53, in fixup_module
  File "mypy\fixup.py", line 150, in visit_symbol_table
AssertionError: ('asyncua.ua.Union-redefinition', 'asyncua.ua.uaprotocol_auto.Union')

(.venv) C:\Temp\mypy>REM ~ Run mypy on the first file which still runs fine. 

(.venv) C:\Temp\mypy>mypy test_1.py 
Success: no issues found in 1 source file

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions