Skip to content

Commit

Permalink
fix: preserve generator error context
Browse files Browse the repository at this point in the history
  • Loading branch information
bzoracler authored Nov 18, 2024
1 parent 8ef2197 commit 66d38ec
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,11 +1223,14 @@ def check_func_def(
if defn.is_async_generator:
if not self.is_async_generator_return_type(typ.ret_type):
self.fail(
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR, typ
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR,
typ.ret_type,
)
else:
if not self.is_generator_return_type(typ.ret_type, defn.is_coroutine):
self.fail(message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ)
self.fail(
message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ.ret_type
)

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

0 comments on commit 66d38ec

Please sign in to comment.