Erase any type variables from a type. Also replace tuple types with the corresponding concrete types. Examples: A -> A B[X] -> B[Any] Tuple[A, B] -> tuple Callable[[A1, A2, ...], R] -> Callable[..., Any] Type[X] -> Type[Any]
(typ: Type)
| 39 | |
| 40 | |
| 41 | def erase_type(typ: Type) -> ProperType: |
| 42 | """Erase any type variables from a type. |
| 43 | |
| 44 | Also replace tuple types with the corresponding concrete types. |
| 45 | |
| 46 | Examples: |
| 47 | A -> A |
| 48 | B[X] -> B[Any] |
| 49 | Tuple[A, B] -> tuple |
| 50 | Callable[[A1, A2, ...], R] -> Callable[..., Any] |
| 51 | Type[X] -> Type[Any] |
| 52 | """ |
| 53 | typ = get_proper_type(typ) |
| 54 | return typ.accept(EraseTypeVisitor()) |
| 55 | |
| 56 | |
| 57 | class EraseTypeVisitor(TypeVisitor[ProperType]): |
searching dependent graphs…