def visit_instance(self, t: types.Instance) -> Set[str]: out = self._visit(t.args) if t.type: # Uses of a class depend on everything in the MRO, # as changes to classes in the MRO can add types to methods, # change property types, change the MRO itself, etc. for s in t.type.mro: out.update(split_module_names(s.module_name)) if t.type.metaclass_type is not None: out.update(split_module_names(t.type.metaclass_type.type.module_name)) return out
def extract_module_names(type_name: Optional[str]) -> List[str]: """Returns the module names of a fully qualified type name.""" if type_name is not None: # Discard the first one, which is just the qualified name of the type possible_module_names = split_module_names(type_name) return possible_module_names[1:] else: return []
def visit_instance(self, t: types.Instance) -> Set[str]: out = self._visit(*t.args) if t.type is not None: out.update(split_module_names(t.type.module_name)) return out