Skip to content

Commit 8f982d5

Browse files
authored
fix: try with the definition context
1 parent 66d38ec commit 8f982d5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

mypy/checker.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,14 +1223,11 @@ 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,
1227-
typ.ret_type,
1226+
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR, defn
12281227
)
12291228
else:
12301229
if not self.is_generator_return_type(typ.ret_type, defn.is_coroutine):
1231-
self.fail(
1232-
message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ.ret_type
1233-
)
1230+
self.fail(message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, defn)
12341231

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

0 commit comments

Comments
 (0)