Skip to content

Commit

Permalink
Merge lookup_fully_qualified and lookup_fully_qualified_or_none (#11205)
Browse files Browse the repository at this point in the history
Partially solves #4157
  • Loading branch information
97littleleaf11 authored Oct 5, 2021
1 parent f7a53d8 commit d1d4316
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4362,22 +4362,10 @@ def create_getattr_var(self, getattr_defn: SymbolTableNode,
return v
return None

def lookup_fully_qualified(self, name: str) -> SymbolTableNode:
"""Lookup a fully qualified name.
Assume that the name is defined. This happens in the global namespace --
the local module namespace is ignored.
Note that this doesn't support visibility, module-level __getattr__, or
nested classes.
"""
parts = name.split('.')
n = self.modules[parts[0]]
for i in range(1, len(parts) - 1):
next_sym = n.names[parts[i]]
assert isinstance(next_sym.node, MypyFile)
n = next_sym.node
return n.names[parts[-1]]
def lookup_fully_qualified(self, fullname: str) -> SymbolTableNode:
ret = self.lookup_fully_qualified_or_none(fullname)
assert ret is not None
return ret

def lookup_fully_qualified_or_none(self, fullname: str) -> Optional[SymbolTableNode]:
"""Lookup a fully qualified name that refers to a module-level definition.
Expand Down

0 comments on commit d1d4316

Please sign in to comment.