def complete(self): leaf = self._module_node.get_leaf_for_position(self._original_position, include_prefixes=True) string, start_leaf, quote = _extract_string_while_in_string( leaf, self._original_position) prefixed_completions = complete_dict( self._module_context, self._code_lines, start_leaf or leaf, self._original_position, None if string is None else quote + string, fuzzy=self._fuzzy, ) if string is not None and not prefixed_completions: prefixed_completions = list( complete_file_name(self._inference_state, self._module_context, start_leaf, quote, string, self._like_name, self._signatures_callback, self._code_lines, self._original_position, self._fuzzy)) if string is not None: if not prefixed_completions and '\n' in string: # Complete only multi line strings prefixed_completions = self._complete_in_string( start_leaf, string) return prefixed_completions cached_name, completion_names = self._complete_python(leaf) completions = list( filter_names(self._inference_state, completion_names, self.stack, self._like_name, self._fuzzy, cached_name=cached_name)) return ( # Removing duplicates mostly to remove False/True/None duplicates. _remove_duplicates(prefixed_completions, completions) + sorted(completions, key=lambda x: (x.name.startswith('__'), x.name.startswith('_'), x.name.lower())))
def complete(self, fuzzy): leaf = self._module_node.get_leaf_for_position(self._position, include_prefixes=True) string, start_leaf = _extract_string_while_in_string( leaf, self._position) if string is not None: completions = list( complete_file_name(self._inference_state, self._module_context, start_leaf, string, self._like_name, self._signatures_callback, self._code_lines, self._original_position, fuzzy)) if completions: return completions completion_names = self._complete_python(leaf) completions = filter_names(self._inference_state, completion_names, self.stack, self._like_name, fuzzy) return sorted( completions, key=lambda x: (x.name.startswith('__'), x.name.startswith('_'), x.name.lower()))