(self, e: YieldExpr)
| 6271 | self.chk.handle_cannot_determine_type(name, context) |
| 6272 | |
| 6273 | def visit_yield_expr(self, e: YieldExpr) -> Type: |
| 6274 | return_type = self.chk.return_types[-1] |
| 6275 | expected_item_type = self.chk.get_generator_yield_type(return_type, False) |
| 6276 | if e.expr is None: |
| 6277 | if ( |
| 6278 | not isinstance(get_proper_type(expected_item_type), (NoneType, AnyType)) |
| 6279 | and self.chk.in_checked_function() |
| 6280 | ): |
| 6281 | self.chk.fail(message_registry.YIELD_VALUE_EXPECTED, e) |
| 6282 | else: |
| 6283 | actual_item_type = self.accept(e.expr, expected_item_type) |
| 6284 | self.chk.check_subtype( |
| 6285 | actual_item_type, |
| 6286 | expected_item_type, |
| 6287 | e, |
| 6288 | message_registry.INCOMPATIBLE_TYPES_IN_YIELD, |
| 6289 | "actual type", |
| 6290 | "expected type", |
| 6291 | ) |
| 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] |
nothing calls this directly
no test coverage detected