Type check a template string expression (t-string). Type-checks all interpolated expressions but the result is always string.templatelib.Template.
(self, e: TemplateStrExpr)
| 5557 | return [], False |
| 5558 | |
| 5559 | def visit_template_str_expr(self, e: TemplateStrExpr) -> Type: |
| 5560 | """Type check a template string expression (t-string). |
| 5561 | |
| 5562 | Type-checks all interpolated expressions but the result is always |
| 5563 | string.templatelib.Template. |
| 5564 | """ |
| 5565 | for item in e.items: |
| 5566 | if isinstance(item, tuple): |
| 5567 | value_expr, _source, _conversion, format_spec = item |
| 5568 | self.accept(value_expr) |
| 5569 | if format_spec is not None: |
| 5570 | self.accept(format_spec) |
| 5571 | sym = lookup_fully_qualified("string.templatelib.Template", self.chk.modules) |
| 5572 | if sym is not None and isinstance(sym.node, TypeInfo): |
| 5573 | return Instance(sym.node, []) |
| 5574 | return AnyType(TypeOfAny.from_error) |
| 5575 | |
| 5576 | def visit_lambda_expr(self, e: LambdaExpr) -> Type: |
| 5577 | """Type check lambda expression.""" |
nothing calls this directly
no test coverage detected