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

Method lookup_qualified

mypy/checker.py:7856–7885  ·  view source on GitHub ↗
(self, name: str)

Source from the content-addressed store, hash-verified

7854 raise KeyError(f"Failed lookup: {name}")
7855
7856 def lookup_qualified(self, name: str) -> SymbolTableNode:
7857 if "." not in name:
7858 return self.lookup(name)
7859 else:
7860 parts = name.split(".")
7861 n = self.modules[parts[0]]
7862 for i in range(1, len(parts) - 1):
7863 sym = n.names.get(parts[i])
7864 assert sym is not None, "Internal error: attempted lookup of unknown name"
7865 assert isinstance(sym.node, MypyFile)
7866 n = sym.node
7867 last = parts[-1]
7868 if last in n.names:
7869 return n.names[last]
7870 elif len(parts) == 2 and parts[0] in ("builtins", "typing"):
7871 fullname = ".".join(parts)
7872 if fullname in SUGGESTED_TEST_FIXTURES:
7873 suggestion = ", e.g. add '[{} fixtures/{}]' to your test".format(
7874 parts[0], SUGGESTED_TEST_FIXTURES[fullname]
7875 )
7876 else:
7877 suggestion = ""
7878 raise KeyError(
7879 "Could not find builtin symbol '{}' (If you are running a "
7880 "test case, use a fixture that "
7881 "defines this symbol{})".format(last, suggestion)
7882 )
7883 else:
7884 msg = "Failed qualified lookup: '{}' (fullname = '{}')."
7885 raise KeyError(msg.format(last, name))
7886
7887 @contextmanager
7888 def enter_partial_types(

Callers 4

_named_typeMethod · 0.95
lookup_typeinfoMethod · 0.95
visit_call_expr_innerMethod · 0.45

Calls 9

lookupMethod · 0.95
rangeClass · 0.85
lenFunction · 0.85
isinstanceFunction · 0.85
KeyErrorClass · 0.85
splitMethod · 0.80
getMethod · 0.45
joinMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected