Check if a given type is an unpack of an unknown type. Unfortunately, there is no robust way to distinguish forward references from genuine undefined names here. But this worked well so far, although it looks quite fragile.
(t: Type)
| 2556 | |
| 2557 | |
| 2558 | def unknown_unpack(t: Type) -> bool: |
| 2559 | """Check if a given type is an unpack of an unknown type. |
| 2560 | |
| 2561 | Unfortunately, there is no robust way to distinguish forward references from |
| 2562 | genuine undefined names here. But this worked well so far, although it looks |
| 2563 | quite fragile. |
| 2564 | """ |
| 2565 | if isinstance(t, UnpackType): |
| 2566 | unpacked = get_proper_type(t.type) |
| 2567 | if isinstance(unpacked, AnyType) and unpacked.type_of_any == TypeOfAny.special_form: |
| 2568 | return True |
| 2569 | return False |
| 2570 | |
| 2571 | |
| 2572 | class FindTypeVarVisitor(SyntheticTypeVisitor[None]): |
no test coverage detected
searching dependent graphs…