def find(self, filters, attribute_lookup): """ :params bool attribute_lookup: Tell to logic if we're accessing the attribute or the contents of e.g. a function. """ names = self.filter_name(filters) if self._found_predefined_types is not None and names: check = flow_analysis.reachability_check( context=self._context, context_scope=self._context.tree_node, node=self._name, ) if check is flow_analysis.UNREACHABLE: return ContextSet() return self._found_predefined_types types = self._names_to_types(names, attribute_lookup) if not names and self._analysis_errors and not types \ and not (isinstance(self._name, tree.Name) and isinstance(self._name.parent.parent, tree.Param)): if isinstance(self._name, tree.Name): if attribute_lookup: analysis.add_attribute_error(self._name_context, self._context, self._name) else: message = ("NameError: name '%s' is not defined." % self._string_name) analysis.add(self._name_context, 'name-error', self._name, message) return types
def find(self, filters, attribute_lookup): """ :params bool attribute_lookup: Tell to logic if we're accessing the attribute or the contents of e.g. a function. """ names = self.filter_name(filters) if self._found_predefined_types is not None and names: check = flow_analysis.reachability_check( self._context, self._context.tree_node, self._name) if check is flow_analysis.UNREACHABLE: return set() return self._found_predefined_types types = self._names_to_types(names, attribute_lookup) if not names and not types \ and not (isinstance(self._name, tree.Name) and isinstance(self._name.parent.parent, tree.Param)): if isinstance(self._name, tree.Name): if attribute_lookup: analysis.add_attribute_error( self._name_context, self._context, self._name) else: message = ("NameError: name '%s' is not defined." % self._string_name) analysis.add(self._name_context, 'name-error', self._name, message) return types
def find(self, scopes, attribute_lookup): """ :params bool attribute_lookup: Tell to logic if we're accessing the attribute or the contents of e.g. a function. """ # TODO rename scopes to names_dicts names = self.filter_name(scopes) if self._found_predefined_if_name is not None: return self._found_predefined_if_name types = self._names_to_types(names, attribute_lookup) if ( not names and not types and not (isinstance(self.name_str, tree.Name) and isinstance(self.name_str.parent.parent, tree.Param)) ): if not isinstance(self.name_str, (str, unicode)): # TODO Remove? if attribute_lookup: analysis.add_attribute_error(self._evaluator, self.scope, self.name_str) else: message = "NameError: name '%s' is not defined." % self.name_str analysis.add(self._evaluator, "name-error", self.name_str, message) debug.dbg("finder._names_to_types: %s -> %s", names, types) return types
def find(self, scopes, attribute_lookup): """ :params bool attribute_lookup: Tell to logic if we're accessing the attribute or the contents of e.g. a function. """ # TODO rename scopes to names_dicts names = self.filter_name(scopes) if self._found_predefined_if_name is not None: return self._found_predefined_if_name types = self._names_to_types(names, attribute_lookup) if not names and not types \ and not (isinstance(self.name_str, tree.Name) and isinstance(self.name_str.parent.parent, tree.Param)): if not isinstance(self.name_str, (str, unicode)): # TODO Remove? if attribute_lookup: analysis.add_attribute_error(self._evaluator, self.scope, self.name_str) else: message = ("NameError: name '%s' is not defined." % self.name_str) analysis.add(self._evaluator, 'name-error', self.name_str, message) debug.dbg('finder._names_to_types: %s -> %s', names, types) return types
def find(self, scopes, search_global=False): names = self.filter_name(scopes) types = self._names_to_types(names, search_global) if not names and not types \ and not (isinstance(self.name_str, pr.Name) and isinstance(self.name_str.parent.parent, pr.Param)): if not isinstance(self.name_str, (str, unicode)): # TODO Remove? if search_global: message = ("NameError: name '%s' is not defined." % self.name_str) analysis.add(self._evaluator, 'name-error', self.name_str, message) else: analysis.add_attribute_error(self._evaluator, self.scope, self.name_str) debug.dbg('finder._names_to_types: %s -> %s', names, types) return types
def find(self, scopes, resolve_decorator=True, search_global=False): names = self.filter_name(scopes) types = self._names_to_types(names, resolve_decorator) if not names and not types \ and not (isinstance(self.name_str, pr.Name) and isinstance(self.name_str.parent.parent, pr.Param)): if not isinstance(self.name_str, (str, unicode)): # TODO Remove? if search_global: message = ("NameError: name '%s' is not defined." % self.name_str) analysis.add(self._evaluator, 'name-error', self.name_str, message) else: analysis.add_attribute_error(self._evaluator, self.scope, self.name_str) debug.dbg('finder._names_to_types: %s -> %s', names, types) return self._resolve_descriptors(types)
def find(self, scopes, search_global=False): # TODO rename scopes to names_dicts names = self.filter_name(scopes) if self._found_predefined_if_name is not None: return self._found_predefined_if_name types = self._names_to_types(names, search_global) if ( not names and not types and not (isinstance(self.name_str, tree.Name) and isinstance(self.name_str.parent.parent, tree.Param)) ): if not isinstance(self.name_str, (str, unicode)): # TODO Remove? if search_global: message = "NameError: name '%s' is not defined." % self.name_str analysis.add(self._evaluator, "name-error", self.name_str, message) else: analysis.add_attribute_error(self._evaluator, self.scope, self.name_str) debug.dbg("finder._names_to_types: %s -> %s", names, types) return types
def find(self, scopes, resolve_decorator=True, search_global=False): if unicode(self.name_str) == 'None': # Filter None, because it's really just a keyword, nobody wants to # access it. return [] names = self.filter_name(scopes) types = self._names_to_types(names, resolve_decorator) if not names and not types \ and not (isinstance(self.name_str, pr.NamePart) and isinstance(self.name_str.parent.parent, pr.Param)): if not isinstance(self.name_str, (str, unicode)): # TODO Remove? if search_global: message = ("NameError: name '%s' is not defined." % self.name_str) analysis.add(self._evaluator, 'name-error', self.name_str, message) else: analysis.add_attribute_error(self._evaluator, self.scope, self.name_str) debug.dbg('finder._names_to_types: %s -> %s', names, types) return self._resolve_descriptors(types)