Skip to content

AssertionError: Must not defer during final iteration on large codebase #15723

Closed as duplicate

Description

@ippeiukai

Crash Report

Running mypy . on a large codebase that has not been type-checked crashed with AssertionError: Must not defer during final iteration.

mypy outputs 481 lines of messages (mostly errors and notes) before crashing.
pyright on the same codebase results in 9756 errors.

Traceback

Traceback (most recent call last):
  File "mypy/semanal.py", line 6451, in accept
  File "mypy/nodes.py", line 786, in accept
  File "mypy/semanal.py", line 833, in visit_func_def
  File "mypy/semanal.py", line 868, in analyze_func_def
  File "mypy/semanal.py", line 6123, in defer
AssertionError: Must not defer during final iteration

To Reproduce

It can be reproduced on our codebase, but no attempt to make small example was successful.
Unfortunately only info we can share publicly is above traceback.
Running mypy only on the file that the INTERNAL ERROR was raised did not result in crash.

Note: rm -rf .mypy_cache/ did not have any effect.

Your Environment

  • Mypy version used: 1.4.1
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used:
  • Operating system and version:

Activity

  1. A5rocks commented on Jul 21, 2023

    @A5rocks
    Collaborator

    Does this reproduce on master? (I doubt anything's changed, but might be nicer!)

  2. wyattscarpenter commented on Sep 21, 2025

    @wyattscarpenter
    Contributor

    Also, were you possibly using the pydantic or django plugins, as mentioned in #15927 and its discussion?

  3. ippeiukai commented on Sep 22, 2025

    @ippeiukai
    Author

    Also, were you possibly using the pydantic or django plugins, as mentioned in #15927 and its discussion?

    I'm quite sure that I was working on a Django project, so django plugin was probably used. Not sure of pydantic.

  4. wyattscarpenter commented on Sep 22, 2025

    @wyattscarpenter
    Contributor

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions