You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[2.0 regression] INTERNAL ERROR: AssertionError in visit_decorator_inner on @types.coroutine generator function #21426
mypy 2.0.0 crashes with an AssertionError (assert isinstance(defn.type, CallableType)) when checking a generator function decorated with @types.coroutine. This is a regression: mypy 1.20.2 accepts the same code without issue. The bug also reproduces on master as of commit 11f945b.
No errors. @types.coroutine is a stdlib decorator that turns a generator function into a coroutine; the same file checks cleanly with mypy 1.x.
Actual Behavior
tiny.py:3: 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.0.0
tiny.py:3: note: use --pdb to drop into pdb
Traceback (most recent call last):
File "mypy/checker.py", line 765, in accept
File "mypy/nodes.py", line 1352, in accept
File "mypy/checker.py", line 5716, in visit_decorator
self.visit_decorator_inner(e)
File "mypy/checker.py", line 5724, in visit_decorator_inner
assert isinstance(defn.type, CallableType)
AssertionError
Your Environment
Mypy version used: 2.0.0 (compiled: yes); confirmed working on 1.20.2
Mypy command-line flags: none (also reproduces with --ignore-missing-imports and --show-traceback)
Mypy configuration options from mypy.ini (and other config files): none
changed the title [-]INTERNAL ERROR: AssertionError in visit_decorator_inner on @types.coroutine generator function (regression in 2.0.0)[/-][+]INTERNAL ERROR: AssertionError in visit_decorator_inner on `@types.coroutine` generator function (regression in 2.0.0)[/+]on May 7, 2026
changed the title [-]INTERNAL ERROR: AssertionError in visit_decorator_inner on `@types.coroutine` generator function (regression in 2.0.0)[/-][+][2.0 regression] INTERNAL ERROR: AssertionError in visit_decorator_inner on `@types.coroutine` generator function[/+]on May 7, 2026
Activity
[-]INTERNAL ERROR: AssertionError in visit_decorator_inner on @types.coroutine generator function (regression in 2.0.0)[/-][+]INTERNAL ERROR: AssertionError in visit_decorator_inner on `@types.coroutine` generator function (regression in 2.0.0)[/+]hauntsaninja commentedon May 7, 2026
Thanks for the great repro! Bisects to #21119
[-]INTERNAL ERROR: AssertionError in visit_decorator_inner on `@types.coroutine` generator function (regression in 2.0.0)[/-][+][2.0 regression] INTERNAL ERROR: AssertionError in visit_decorator_inner on `@types.coroutine` generator function[/+]ilevkivskyi commentedon May 7, 2026
It looks like the problem appears when the decorated function doesn't have any type annotations. I will take a look at this.
Fix broken refactor of awaitable generator patching (#21435)