def get_callsites(self, func: FuncDef) -> Tuple[List[Callsite], List[str]]: """Find all call sites of a function.""" new_type = self.get_trivial_type(func) collector_plugin = SuggestionPlugin(func.fullname()) self.plugin._plugins.insert(0, collector_plugin) try: errors = self.try_type(func, new_type) finally: self.plugin._plugins.pop(0) return collector_plugin.mystery_hits, errors
def try_type(self, func: FuncDef, typ: Type) -> List[str]: """Recheck a function while assuming it has type typ. Return all error messages. """ old = func.unanalyzed_type # During reprocessing, unanalyzed_type gets copied to type (by aststrip). # We don't modify type because it isn't necessary and it # would mess up the snapshotting. func.unanalyzed_type = typ try: res = self.fgmanager.trigger(func.fullname()) # if res: # print('\n'.join(res)) return res finally: func.unanalyzed_type = old
def try_type(self, func: FuncDef, typ: ProperType) -> List[str]: """Recheck a function while assuming it has type typ. Return all error messages. """ old = func.unanalyzed_type # During reprocessing, unanalyzed_type gets copied to type (by aststrip). # We set type to None to ensure that the type always changes during # reprocessing. func.type = None func.unanalyzed_type = typ try: res = self.fgmanager.trigger(func.fullname()) # if res: # print('===', typ) # print('\n'.join(res)) return res finally: func.unanalyzed_type = old