1
0
forked from VimPlug/jedi

pep cleanups

This commit is contained in:
Dave Halter
2013-12-24 11:47:28 +01:00
parent 5b33de991b
commit e4013cee77
4 changed files with 11 additions and 16 deletions

View File

@@ -160,7 +160,7 @@ class Script(object):
and n.lower().startswith(like.lower()) \ and n.lower().startswith(like.lower()) \
or n.startswith(like): or n.startswith(like):
if not evaluate.filter_private_variable(s, if not evaluate.filter_private_variable(s,
user_stmt or self._parser.user_scope, n): user_stmt or self._parser.user_scope, n):
new = api_classes.Completion(c, needs_dot, len(like), s) new = api_classes.Completion(c, needs_dot, len(like), s)
k = (new.name, new.complete) # key k = (new.name, new.complete) # key
if k in comp_dct and settings.no_completion_duplicates: if k in comp_dct and settings.no_completion_duplicates:
@@ -552,7 +552,6 @@ class Script(object):
cur_name_part = name_part cur_name_part = name_part
kill_count += 1 kill_count += 1
context = self._module.get_context() context = self._module.get_context()
just_from = next(context) == 'from' just_from = next(context) == 'from'
@@ -658,8 +657,6 @@ class Interpreter(Script):
return completions return completions
def defined_names(source, path=None, encoding='utf-8'): def defined_names(source, path=None, encoding='utf-8'):
""" """
Get all definitions in `source` sorted by its position. Get all definitions in `source` sorted by its position.

View File

@@ -51,8 +51,7 @@ def follow_param(param):
param_str) param_str)
user_position = (2, 0) user_position = (2, 0)
p = Parser(param_str, None, user_position, p = Parser(param_str, None, user_position, no_docstr=True)
no_docstr=True)
if p.user_stmt is None: if p.user_stmt is None:
return [] return []
return evaluate.follow_statement(p.user_stmt) return evaluate.follow_statement(p.user_stmt)

View File

@@ -147,9 +147,9 @@ class ParamListener(object):
def search_params(param): def search_params(param):
""" """
This is a dynamic search for params. If you try to complete a type: This is a dynamic search for params. If you try to complete a type:
>>> def func(foo): >>> def func(foo):
>>> # here is the completion ... foo
>>> foo
>>> func(1) >>> func(1)
>>> func("") >>> func("")
@@ -186,12 +186,12 @@ def search_params(param):
# ``follow_call_path`` on the call_path and it would # ``follow_call_path`` on the call_path and it would
# also work. # also work.
def listRightIndex(lst, value): def listRightIndex(lst, value):
return len(lst) - lst[-1::-1].index(value) -1 return len(lst) - lst[-1::-1].index(value) - 1
# Need to take right index, because there could be a # Need to take right index, because there could be a
# func usage before. # func usage before.
i = listRightIndex(call_path, func_name) i = listRightIndex(call_path, func_name)
first, last = call_path[:i], call_path[i+1:] first, last = call_path[:i], call_path[i + 1:]
if not last and not call_path.index(func_name) != i: if not last and not call_path.index(func_name) != i:
continue continue
scopes = [scope] scopes = [scope]
@@ -204,9 +204,8 @@ def search_params(param):
resolve_decorator=False) resolve_decorator=False)
c = [getattr(escope, 'base_func', None) or escope.base c = [getattr(escope, 'base_func', None) or escope.base
for escope in s for escope in s
if escope.isinstance(er.Function, er.Class) if escope.isinstance(er.Function, er.Class)]
]
if compare in c: if compare in c:
# only if we have the correct function we execute # only if we have the correct function we execute
# it, otherwise just ignore it. # it, otherwise just ignore it.

View File

@@ -264,7 +264,7 @@ def find_name(scope, name_str, position=None, search_global=False,
t = 'tuple' if c == '*' else 'dict' t = 'tuple' if c == '*' else 'dict'
res_new = [er.Instance( res_new = [er.Instance(
find_name(builtin.Builtin.scope, t)[0]) find_name(builtin.Builtin.scope, t)[0])
] ]
if not r.assignment_details: if not r.assignment_details:
# this means that there are no default params, # this means that there are no default params,
# so just ignore it. # so just ignore it.
@@ -436,8 +436,8 @@ def find_name(scope, name_str, position=None, search_global=False,
if not result and isinstance(nscope, er.Instance): if not result and isinstance(nscope, er.Instance):
# __getattr__ / __getattribute__ # __getattr__ / __getattribute__
result += check_getattr(nscope, name_str) result += check_getattr(nscope, name_str)
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, scope, debug.dbg('sfn filter "%s" in (%s-%s): %s@%s'
nscope, u(result), position)) % (name_str, scope, nscope, u(result), position))
return result return result
def descriptor_check(result): def descriptor_check(result):