MCPcopy Index your code
hub / github.com/python/mypy / lookup_fully_qualified_alias

Function lookup_fully_qualified_alias

mypy/fixup.py:389–416  ·  view source on GitHub ↗
(
    modules: dict[str, MypyFile], name: str, *, allow_missing: bool
)

Source from the content-addressed store, hash-verified

387
388
389def lookup_fully_qualified_alias(
390 modules: dict[str, MypyFile], name: str, *, allow_missing: bool
391) -> TypeAlias:
392 stnode = lookup_fully_qualified(name, modules, raise_on_missing=not allow_missing)
393 node = stnode.node if stnode else None
394 if isinstance(node, TypeAlias):
395 return node
396 elif isinstance(node, TypeInfo):
397 if node.special_alias:
398 # Already fixed up.
399 return node.special_alias
400 if node.tuple_type:
401 alias = TypeAlias.from_tuple_type(node)
402 elif node.typeddict_type:
403 alias = TypeAlias.from_typeddict_type(node)
404 else:
405 assert allow_missing
406 return missing_alias()
407 node.special_alias = alias
408 return alias
409 else:
410 # Looks like a missing TypeAlias during an initial daemon load, put something there
411 assert (
412 allow_missing
413 ), "Should never get here in normal mode, got {}:{} instead of TypeAlias".format(
414 type(node).__name__, node.fullname if node else ""
415 )
416 return missing_alias()
417
418
419_SUGGESTION: Final = "<missing {}: *should* have gone away during fine-grained update>"

Callers 1

visit_type_alias_typeMethod · 0.85

Calls 7

lookup_fully_qualifiedFunction · 0.90
isinstanceFunction · 0.85
missing_aliasFunction · 0.85
typeClass · 0.85
from_tuple_typeMethod · 0.80
from_typeddict_typeMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…