mypy icon indicating copy to clipboard operation
mypy copied to clipboard

AssertionError: Must not defer during final iteration & TypeError: '<' not supported between instances of 'ArgKind' and 'ArgKind'

Open CoolCat467 opened this issue 3 years ago • 0 comments

Crash Report

Basically, I am trying to program a game with the Trio asynchronous library. Using the mypy daemon and type checking different files makes it crash. Trying to make excerpt files for demonstrating the issue, I also found that I would encounter AssertionError: Must not defer during final iteration if I had the setup slightly different.

Traceback

If you type check main.py and then type check with_trio.py, you get this traceback from the log file:

/home/<my_username>/.local/lib/python3.11/site-packages/trio-stubs/__init__.pyi:285: 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: 0.991
/home/<my_username>/.local/lib/python3.11/site-packages/trio-stubs/__init__.pyi: 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: 0.991
Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 229, in serve
  File "mypy/dmypy_server.py", line 274, in run_command
  File "mypy/dmypy_server.py", line 342, in cmd_run
  File "mypy/dmypy_server.py", line 411, in check
  File "mypy/dmypy_server.py", line 595, in fine_grained_increment_follow_imports
  File "mypy/server/update.py", line 263, in update
  File "mypy/server/update.py", line 365, in update_one
  File "mypy/server/update.py", line 427, in update_module
  File "mypy/server/update.py", line 650, in update_module_isolated
  File "mypy/semanal_main.py", line 85, in semantic_analysis_for_scc
  File "mypy/semanal_main.py", line 243, in process_functions
  File "mypy/semanal_main.py", line 282, in process_top_level_function
  File "mypy/semanal_main.py", line 339, in semantic_analyze_target
  File "mypy/semanal.py", line 581, in refresh_partial
  File "mypy/semanal.py", line 6049, in accept
  File "mypy/errors.py", line 1149, in report_internal_error
  File "mypy/semanal.py", line 6047, in accept
  File "mypy/nodes.py", line 822, in accept
  File "mypy/semanal.py", line 808, in visit_func_def
  File "mypy/semanal.py", line 837, in analyze_func_def
  File "mypy/typeanal.py", line 865, in visit_callable_type
  File "mypy/typeanal.py", line 1391, in anal_array
  File "mypy/typeanal.py", line 1400, in anal_type
  File "mypy/types.py", line 2738, in accept
  File "mypy/typeanal.py", line 1050, in visit_type_type
  File "mypy/typeanal.py", line 1400, in anal_type
  File "mypy/types.py", line 2172, in accept
  File "mypy/typeanal.py", line 979, in visit_tuple_type
  File "mypy/typeanal.py", line 1391, in anal_array
  File "mypy/typeanal.py", line 1400, in anal_type
  File "mypy/types.py", line 2782, in accept
  File "mypy/typeanal.py", line 1055, in visit_placeholder_type
  File "mypy/semanal.py", line 5724, in defer
AssertionError: Must not defer during final iteration

If you type check with_trio.py and then type check main.py, you get this traceback from the log file:

Traceback (most recent call last):
  File "mypy/dmypy_server.py", line 229, in serve
  File "mypy/dmypy_server.py", line 274, in run_command
  File "mypy/dmypy_server.py", line 342, in cmd_run
  File "mypy/dmypy_server.py", line 411, in check
  File "mypy/dmypy_server.py", line 659, in fine_grained_increment_follow_imports
  File "mypy/server/update.py", line 263, in update
  File "mypy/server/update.py", line 365, in update_one
  File "mypy/server/update.py", line 422, in update_module
  File "mypy/server/astdiff.py", line 205, in snapshot_symbol_table
  File "mypy/server/astdiff.py", line 278, in snapshot_definition
  File "mypy/server/astdiff.py", line 205, in snapshot_symbol_table
  File "mypy/server/astdiff.py", line 249, in snapshot_definition
  File "mypy/server/astdiff.py", line 294, in snapshot_optional_type
  File "mypy/server/astdiff.py", line 289, in snapshot_type
  File "mypy/types.py", line 1792, in accept
  File "mypy/server/astdiff.py", line 406, in visit_callable_type
  File "mypy/server/astdiff.py", line 300, in snapshot_types
  File "mypy/server/astdiff.py", line 289, in snapshot_type
  File "mypy/types.py", line 2592, in accept
  File "mypy/server/astdiff.py", line 447, in visit_union_type
TypeError: '<' not supported between instances of 'ArgKind' and 'ArgKind'

To Reproduce

With the following files in a folder with nothing else

In main.py:

import does_not_exist

In with_trio.py:

import trio

In recreate.sh:

#!/bin/bash
# -*- coding: utf-8 -*-

# "AssertionError: Must not defer during final iteration" one:
dmypy start -- --warn-unused-ignores --show-error-codes --show-traceback --strict --show-absolute-path --disallow-untyped-calls --no-warn-no-return --show-column-numbers --no-color-output --warn-redundant-casts --disallow-untyped-defs --no-implicit-reexport --warn-unreachable --no-error-summary
dmypy check main.py --export-types
dmypy check with_trio.py --export-types

# "TypeError: '<' not supported between instances of 'ArgKind' and 'ArgKind'" one:
dmypy start -- --warn-unused-ignores --show-error-codes --show-traceback --strict --show-absolute-path --disallow-untyped-calls --no-warn-no-return --show-column-numbers --no-color-output --warn-redundant-casts --disallow-untyped-defs --no-implicit-reexport --warn-unreachable --no-error-summary
dmypy check with_trio.py --export-types
dmypy check main.py --export-types

Assuming you don't already have a daemon running, Run recreate.sh. There are more than one dmypy start command because it crashes in-between the two setups.

Your Environment

trio==0.22.0 trio-typing==0.7.0

  • Mypy version used: 0.991
  • Mypy command-line flags: See listed recreate.sh file for all daemon flags
  • Mypy configuration options from mypy.ini (and other config files): No other configuration files
  • Python version used: Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0]
  • Operating system and version: 64 bit Linux Ubuntu Budgie 10.6.1 (Ubuntu 22.04.1 LTS)

CoolCat467 avatar Dec 21 '22 03:12 CoolCat467