MCPcopy
hub / github.com/python/mypy / unknown_unpack

Function unknown_unpack

mypy/typeanal.py:2558–2569  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2556
2557
2558def 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
2572class FindTypeVarVisitor(SyntheticTypeVisitor[None]):

Callers 2

instantiate_type_aliasFunction · 0.85
validate_instanceFunction · 0.85

Calls 2

get_proper_typeFunction · 0.90
isinstanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…