mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
cleaning / pep8
This commit is contained in:
@@ -8,6 +8,7 @@ try:
|
||||
next = next
|
||||
except NameError:
|
||||
_raiseStopIteration = object()
|
||||
|
||||
def next(iterator, default=_raiseStopIteration):
|
||||
if not hasattr(iterator, 'next'):
|
||||
raise TypeError("not an iterator")
|
||||
|
||||
10
builtin.py
10
builtin.py
@@ -36,10 +36,6 @@ class CachedModule(object):
|
||||
def _load_module(self):
|
||||
source = self._get_source()
|
||||
self._parser = parsing.PyFuzzyParser(source, self.path or self.name)
|
||||
#except:
|
||||
# debug.warning('not possible to resolve', self.name, source)
|
||||
#open('builtin_fail', 'w').write(code)
|
||||
# raise
|
||||
p_time = None if not self.path else os.path.getmtime(self.path)
|
||||
|
||||
self.cache[self.path or self.name] = p_time, self._parser
|
||||
@@ -163,10 +159,10 @@ class Parser(CachedModule):
|
||||
try:
|
||||
try:
|
||||
path = scope.__file__
|
||||
except:
|
||||
except AttributeError:
|
||||
path = '?'
|
||||
code += '# Generated module %s from %s\n' % (scope.__name__, path)
|
||||
except:
|
||||
except AttributeError:
|
||||
pass
|
||||
code += '"""\n%s\n"""\n' % scope.__doc__
|
||||
|
||||
@@ -189,7 +185,7 @@ class Parser(CachedModule):
|
||||
doc_str = parsing.indent_block('"""\n%s\n"""\n' % func.__doc__)
|
||||
try:
|
||||
mixin = self.mixin_funcs[name]
|
||||
except:
|
||||
except KeyError:
|
||||
# normal code generation
|
||||
code += 'def %s(%s):\n' % (name, params)
|
||||
code += doc_str
|
||||
|
||||
@@ -251,7 +251,7 @@ class Instance(Executable):
|
||||
"""
|
||||
try:
|
||||
return func.params[0].used_vars[0].names[0]
|
||||
except:
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def get_defined_names(self):
|
||||
@@ -414,7 +414,7 @@ class Execution(Executable):
|
||||
Get the return vars of a function.
|
||||
"""
|
||||
stmts = []
|
||||
#print '\n\n', self.var_args, self.var_args.values, self.var_args.parent_stmt
|
||||
#a = self.var_args; print '\n\n', a, a.values, a.parent_stmt
|
||||
if isinstance(self.base, Class):
|
||||
# there maybe executions of executions
|
||||
stmts = [Instance(self.base, self.var_args)]
|
||||
@@ -442,8 +442,8 @@ class Execution(Executable):
|
||||
# TODO how can we deactivate this again?
|
||||
#self.base.param_cb = None
|
||||
|
||||
# func could have changed because of decorators, so clear them
|
||||
# again
|
||||
# func could have changed because of decorators, so clear
|
||||
# them again
|
||||
self.base.is_decorated = False
|
||||
else:
|
||||
debug.warning("no execution possible", func)
|
||||
@@ -488,6 +488,7 @@ class Generator(object):
|
||||
def __repr__(self):
|
||||
return "<%s of %s>" % (self.__class__.__name__, self.func)
|
||||
|
||||
|
||||
class Array(object):
|
||||
"""
|
||||
Used as a mirror to parsing.Array, if needed. It defines some getter
|
||||
|
||||
@@ -107,6 +107,7 @@ class Definition(object):
|
||||
def __repr__(self):
|
||||
return "<%s %s>" % (self.__class__.__name__, self)
|
||||
|
||||
|
||||
def get_completion_parts(path):
|
||||
"""
|
||||
Returns the parts for the completion
|
||||
@@ -133,7 +134,8 @@ def complete(source, row, column, source_path):
|
||||
:rtype: list
|
||||
"""
|
||||
try:
|
||||
scopes, path, dot, like = prepare_goto(source, row, column, source_path, True)
|
||||
scopes, path, dot, like = prepare_goto(source, row, column,
|
||||
source_path, True)
|
||||
except NotFoundError:
|
||||
# normally this would be used like this: `NotFoundError as exc`, but
|
||||
# this guarantues backwards compatibility with Python2.5.
|
||||
@@ -200,6 +202,7 @@ def prepare_goto(source, row, column, source_path, is_like_search):
|
||||
else:
|
||||
return scopes
|
||||
|
||||
|
||||
def get_definitions(source, row, column, source_path):
|
||||
"""
|
||||
Returns the definitions of a the path under the cursor.
|
||||
|
||||
Reference in New Issue
Block a user