MCPcopy Index your code
hub / github.com/python/mypy / visit_await_expr

Method visit_await_expr

mypy/checkexpr.py:6294–6306  ·  view source on GitHub ↗
(self, e: AwaitExpr, allow_none_return: bool = False)

Source from the content-addressed store, hash-verified

6292 return self.chk.get_generator_receive_type(return_type, False)
6293
6294 def visit_await_expr(self, e: AwaitExpr, allow_none_return: bool = False) -> Type:
6295 expected_type = self.type_context[-1]
6296 if expected_type is not None:
6297 expected_type = self.chk.named_generic_type("typing.Awaitable", [expected_type])
6298 actual_type = get_proper_type(self.accept(e.expr, expected_type))
6299 if isinstance(actual_type, AnyType):
6300 return AnyType(TypeOfAny.from_another_any, source_any=actual_type)
6301 ret = self.check_awaitable_expr(
6302 actual_type, e, message_registry.INCOMPATIBLE_TYPES_IN_AWAIT
6303 )
6304 if not allow_none_return and isinstance(get_proper_type(ret), NoneType):
6305 self.chk.msg.does_not_return_value(None, e)
6306 return ret
6307
6308 def check_awaitable_expr(
6309 self, t: Type, ctx: Context, msg: str | ErrorMessage, ignore_binder: bool = False

Callers 1

acceptMethod · 0.95

Calls 7

acceptMethod · 0.95
check_awaitable_exprMethod · 0.95
get_proper_typeFunction · 0.90
AnyTypeClass · 0.90
isinstanceFunction · 0.85
does_not_return_valueMethod · 0.80
named_generic_typeMethod · 0.45

Tested by

no test coverage detected