Check the argument to `await` and extract the type of value. Also used by `async for` and `async with`.
(
self, t: Type, ctx: Context, msg: str | ErrorMessage, ignore_binder: bool = False
)
| 6306 | return ret |
| 6307 | |
| 6308 | def check_awaitable_expr( |
| 6309 | self, t: Type, ctx: Context, msg: str | ErrorMessage, ignore_binder: bool = False |
| 6310 | ) -> Type: |
| 6311 | """Check the argument to `await` and extract the type of value. |
| 6312 | |
| 6313 | Also used by `async for` and `async with`. |
| 6314 | """ |
| 6315 | if not self.chk.check_subtype( |
| 6316 | t, self.named_type("typing.Awaitable"), ctx, msg, "actual type", "expected type" |
| 6317 | ): |
| 6318 | return AnyType(TypeOfAny.special_form) |
| 6319 | else: |
| 6320 | generator = self.check_method_call_by_name("__await__", t, [], [], ctx)[0] |
| 6321 | ret_type = self.chk.get_generator_return_type(generator, False) |
| 6322 | ret_type = get_proper_type(ret_type) |
| 6323 | if ( |
| 6324 | not ignore_binder |
| 6325 | and isinstance(ret_type, UninhabitedType) |
| 6326 | and not ret_type.ambiguous |
| 6327 | ): |
| 6328 | self.chk.binder.unreachable() |
| 6329 | return ret_type |
| 6330 | |
| 6331 | def visit_yield_from_expr(self, e: YieldFromExpr, allow_none_return: bool = False) -> Type: |
| 6332 | # NOTE: Whether `yield from` accepts an `async def` decorated |
no test coverage detected