Get the declared or inferred type of a RefExpr expression. Return None if there is no type or the expression is not a RefExpr. This can return None if the type hasn't been inferred yet.
(expr: BindableExpression)
| 635 | |
| 636 | |
| 637 | def get_declaration(expr: BindableExpression) -> Type | None: |
| 638 | """Get the declared or inferred type of a RefExpr expression. |
| 639 | |
| 640 | Return None if there is no type or the expression is not a RefExpr. |
| 641 | This can return None if the type hasn't been inferred yet. |
| 642 | """ |
| 643 | if isinstance(expr, RefExpr): |
| 644 | if isinstance(expr.node, Var): |
| 645 | type = expr.node.type |
| 646 | if not isinstance(get_proper_type(type), PartialType): |
| 647 | return type |
| 648 | elif isinstance(expr.node, TypeInfo): |
| 649 | return TypeType(fill_typevars_with_any(expr.node)) |
| 650 | return None |
| 651 | |
| 652 | |
| 653 | def collapse_variadic_union(typ: UnionType) -> Type: |
no test coverage detected
searching dependent graphs…