diff --git a/jedi/api.py b/jedi/api.py index fe746bc5..017a3056 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -94,7 +94,7 @@ class Script(object): scopes = list(self._prepare_goto(path, True)) except NotFoundError: scopes = [] - scope_generator = evaluate.get_names_for_scope( + scope_generator = evaluate.get_names_of_scope( self._parser.user_scope, self.pos) completions = [] for scope, name_list in scope_generator: diff --git a/jedi/evaluate.py b/jedi/evaluate.py index 5cfd454c..70e74b00 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -113,10 +113,10 @@ def get_defined_names_for_position(scope, position=None, start_scope=None): return names_new -def get_names_for_scope(scope, position=None, star_search=True, +def get_names_of_scope(scope, position=None, star_search=True, include_builtin=True): """ - Get all completions possible for the current scope. + Get all completions (names) possible for the current scope. The star search option is only here to provide an optimization. Otherwise the whole thing would probably start a little recursive madness. """ @@ -153,7 +153,7 @@ def get_names_for_scope(scope, position=None, star_search=True, # Add star imports. if star_search: for s in imports.remove_star_imports(non_flow.get_parent_until()): - for g in get_names_for_scope(s, star_search=False): + for g in get_names_of_scope(s, star_search=False): yield g # Add builtins to the global scope. @@ -378,13 +378,13 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False, break if not result and isinstance(nscope, er.Instance): - # getattr() / __getattr__ / __getattribute__ + # __getattr__ / __getattribute__ result += check_getattr(nscope, name_str) debug.dbg('sfn filter "%s" in %s: %s' % (name_str, nscope, result)) return result def descriptor_check(result): - """ Processes descriptors """ + """Processes descriptors""" res_new = [] for r in result: if isinstance(scope, (er.Instance, er.Class)) \ @@ -399,7 +399,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False, return res_new if search_global: - scope_generator = get_names_for_scope(scope, position=position) + scope_generator = get_names_of_scope(scope, position=position) else: if isinstance(scope, er.Instance): scope_generator = scope.scope_generator() @@ -418,6 +418,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False, def check_getattr(inst, name_str): + """Checks for both __getattr__ and __getattribute__ methods""" result = [] # str is important to lose the NamePart! name = pr.Call(str(name_str), pr.Call.STRING, (0, 0), inst) @@ -439,7 +440,7 @@ def check_getattr(inst, name_str): def get_iterator_types(inputs): - """ Returns the types of any iterator (arrays, yields, __iter__, etc). """ + """Returns the types of any iterator (arrays, yields, __iter__, etc).""" iterators = [] # Take the first statement (for has always only # one, remember `in`). And follow it. @@ -482,7 +483,7 @@ def assign_tuples(tup, results, seek_name): >>> a, b = 1, "" >>> a, (b, c) = 1, ("", 1.0) - Here, if seek_name is "a", the number type will be returned. + Here, if `seek_name` is "a", the number type will be returned. The first part (before `=`) is the param tuples, the second one result. :type tup: pr.Array @@ -643,7 +644,7 @@ def follow_call_list(call_list, follow_array=False): def follow_call(call): - """ Follow a call is following a function, variable, string, etc. """ + """Follow a call is following a function, variable, string, etc.""" scope = call.parent_stmt.parent path = call.generate_call_path() position = call.parent_stmt.start_pos @@ -651,7 +652,7 @@ def follow_call(call): def follow_call_path(path, scope, position): - """ Follows a path generated by `pr.Call.generate_call_path()` """ + """Follows a path generated by `pr.Call.generate_call_path()`""" current = next(path) if isinstance(current, pr.Array): @@ -739,6 +740,7 @@ def follow_path(path, scope, call_scope, position=None): def filter_private_variable(scope, call_scope, var_name): + """private variables begin with a double underline `__`""" if isinstance(var_name, (str, unicode)) \ and var_name.startswith('__') and isinstance(scope, er.Instance): s = call_scope.get_parent_until((pr.Class, er.Instance)) diff --git a/jedi/imports.py b/jedi/imports.py index 6cb28154..f622f622 100644 --- a/jedi/imports.py +++ b/jedi/imports.py @@ -117,7 +117,7 @@ class ImportPath(pr.Base): and scope.path.endswith('__init__.py'): pkg_path = os.path.dirname(scope.path) names += self.get_module_names([pkg_path]) - for s, scope_names in evaluate.get_names_for_scope(scope, + for s, scope_names in evaluate.get_names_of_scope(scope, include_builtin=False): for n in scope_names: if self.import_stmt.from_ns is None \