Skip to content

Commit 66d38ec

Browse files
authored
fix: preserve generator error context
1 parent 8ef2197 commit 66d38ec

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mypy/checker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,11 +1223,14 @@ def check_func_def(
12231223
if defn.is_async_generator:
12241224
if not self.is_async_generator_return_type(typ.ret_type):
12251225
self.fail(
1226-
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR, typ
1226+
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR,
1227+
typ.ret_type,
12271228
)
12281229
else:
12291230
if not self.is_generator_return_type(typ.ret_type, defn.is_coroutine):
1230-
self.fail(message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ)
1231+
self.fail(
1232+
message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ.ret_type
1233+
)
12311234

12321235
# Fix the type if decorated with `@types.coroutine` or `@asyncio.coroutine`.
12331236
if defn.is_awaitable_coroutine:

0 commit comments

Comments
 (0)