1
0
forked from VimPlug/jedi

Merge branch 'dev' of github.com:davidhalter/jedi into dev

This commit is contained in:
David Halter
2012-10-21 02:08:50 +02:00
4 changed files with 41 additions and 41 deletions

View File

@@ -542,7 +542,7 @@ def check_statement_information(stmt, search_name):
classes_call = isinst[1][0] # class_or_type_or_tuple classes_call = isinst[1][0] # class_or_type_or_tuple
assert isinstance(classes_call, parsing.Call) assert isinstance(classes_call, parsing.Call)
result = [] result = []
for c in evaluate.follow_call(classes_call): for c in evaluate.follow_call(classes_call):
if isinstance(c, evaluate.Array): if isinstance(c, evaluate.Array):
result += c.get_index_types() result += c.get_index_types()
else: else:

View File

@@ -68,7 +68,7 @@ def imitate_pydoc(string):
pass pass
get_target = lambda s: h.topics.get(s, h.keywords.get(s)) get_target = lambda s: h.topics.get(s, h.keywords.get(s))
while type(string) == type(''): while isinstance(string, str):
string = get_target(string) string = get_target(string)
try: try:

View File

@@ -250,7 +250,7 @@ def sys_path_with_modifications(module):
if call.execution is None: if call.execution is None:
continue continue
exe = call.execution exe = call.execution
if not (array_cmd == 'insert' and len(exe) == 2 \ if not (array_cmd == 'insert' and len(exe) == 2
or array_cmd == 'append' and len(exe) == 1): or array_cmd == 'append' and len(exe) == 1):
continue continue

View File

@@ -44,7 +44,7 @@ class ParserError(Exception):
pass pass
def indent_block(text, indention=" "): def indent_block(text, indention=' '):
""" This function indents a text block with a default of four spaces """ """ This function indents a text block with a default of four spaces """
temp = '' temp = ''
while text and text[-1] == '\n': while text and text[-1] == '\n':
@@ -176,7 +176,7 @@ class Scope(Simple):
i += s.get_imports() i += s.get_imports()
return i return i
def get_code(self, first_indent=False, indention=" "): def get_code(self, first_indent=False, indention=' '):
""" """
:return: Returns the code of the current scope. :return: Returns the code of the current scope.
:rtype: str :rtype: str
@@ -220,8 +220,8 @@ class Scope(Simple):
return n return n
def get_defined_names(self): def get_defined_names(self):
return [n for n in self.get_set_vars() \ return [n for n in self.get_set_vars()
if isinstance(n, Import) or len(n) == 1] if isinstance(n, Import) or len(n) == 1]
def is_empty(self): def is_empty(self):
""" """
@@ -325,17 +325,17 @@ class Class(Scope):
s.parent = weakref.ref(self) s.parent = weakref.ref(self)
self.decorators = [] self.decorators = []
def get_code(self, first_indent=False, indention=" "): def get_code(self, first_indent=False, indention=' '):
str = "\n".join('@' + stmt.get_code() for stmt in self.decorators) string = "\n".join('@' + stmt.get_code() for stmt in self.decorators)
str += 'class %s' % (self.name) string += 'class %s' % (self.name)
if len(self.supers) > 0: if len(self.supers) > 0:
sup = ','.join(stmt.code for stmt in self.supers) sup = ','.join(stmt.code for stmt in self.supers)
str += '(%s)' % sup string += '(%s)' % sup
str += ':\n' string += ':\n'
str += super(Class, self).get_code(True, indention) string += super(Class, self).get_code(True, indention)
if self.is_empty(): if self.is_empty():
str += "pass\n" string += "pass\n"
return str return string
class Function(Scope): class Function(Scope):
@@ -367,14 +367,14 @@ class Function(Scope):
annotation.parent = weakref.ref(self) annotation.parent = weakref.ref(self)
self.annotation = annotation self.annotation = annotation
def get_code(self, first_indent=False, indention=" "): def get_code(self, first_indent=False, indention=' '):
str = "\n".join('@' + stmt.get_code() for stmt in self.decorators) string = "\n".join('@' + stmt.get_code() for stmt in self.decorators)
params = ','.join([stmt.code for stmt in self.params]) params = ','.join([stmt.code for stmt in self.params])
str += "def %s(%s):\n" % (self.name, params) string += "def %s(%s):\n" % (self.name, params)
str += super(Function, self).get_code(True, indention) string += super(Function, self).get_code(True, indention)
if self.is_empty(): if self.is_empty():
str += "pass\n" string += "pass\n"
return str return string
def get_set_vars(self): def get_set_vars(self):
n = super(Function, self).get_set_vars() n = super(Function, self).get_set_vars()
@@ -418,7 +418,7 @@ class Flow(Scope):
self.inits = inits self.inits = inits
for s in inits: for s in inits:
s.parent = weakref.ref(self) s.parent = weakref.ref(self)
if set_vars == None: if set_vars is None:
self.set_vars = [] self.set_vars = []
else: else:
self.set_vars = set_vars self.set_vars = set_vars
@@ -436,16 +436,16 @@ class Flow(Scope):
if self.next: if self.next:
self.next.parent = value self.next.parent = value
def get_code(self, first_indent=False, indention=" "): def get_code(self, first_indent=False, indention=' '):
stmts = [] stmts = []
for s in self.inits: for s in self.inits:
stmts.append(s.get_code(new_line=False)) stmts.append(s.get_code(new_line=False))
stmt = ', '.join(stmts) stmt = ', '.join(stmts)
str = "%s %s:\n" % (self.command, vars, stmt) string = "%s %s:\n" % (self.command, vars, stmt)
str += super(Flow, self).get_code(True, indention) string += super(Flow, self).get_code(True, indention)
if self.next: if self.next:
str += self.next.get_code() string += self.next.get_code()
return str return string
def get_set_vars(self, is_internal_call=False): def get_set_vars(self, is_internal_call=False):
""" """
@@ -522,8 +522,8 @@ class Import(Simple):
:param defunct: An Import is valid or not. :param defunct: An Import is valid or not.
:type defunct: bool :type defunct: bool
""" """
def __init__(self, start_pos, end_pos, namespace, alias=None, \ def __init__(self, start_pos, end_pos, namespace, alias=None,
from_ns=None, star=False, relative_count=0, defunct=False): from_ns=None, star=False, relative_count=0, defunct=False):
super(Import, self).__init__(start_pos, end_pos) super(Import, self).__init__(start_pos, end_pos)
self.namespace = namespace self.namespace = namespace
@@ -807,7 +807,7 @@ class Statement(Simple):
if level != 0: if level != 0:
debug.warning("Brackets don't match: %s." debug.warning("Brackets don't match: %s."
"This is not normal behaviour." % level) "This is not normal behaviour." % level)
self._assignment_calls_calculated = True self._assignment_calls_calculated = True
self._assignment_calls = top self._assignment_calls = top
@@ -819,10 +819,10 @@ class Param(Statement):
The class which shows definitions of params of classes and functions. The class which shows definitions of params of classes and functions.
But this is not to define function calls. But this is not to define function calls.
""" """
def __init__(self, code, set_vars, used_funcs, used_vars, token_list, def __init__(self, code, set_vars, used_funcs, used_vars,
start_pos, end_pos): token_list, start_pos, end_pos):
super(Param, self).__init__(code, set_vars, used_funcs, super(Param, self).__init__(code, set_vars, used_funcs, used_vars,
used_vars, token_list, start_pos, end_pos) token_list, start_pos, end_pos)
# this is defined by the parser later on, not at the initialization # this is defined by the parser later on, not at the initialization
# it is the position in the call (first argument, second...) # it is the position in the call (first argument, second...)
@@ -1024,10 +1024,10 @@ class Array(Call):
return str(el) return str(el)
map = {Array.NOARRAY: '%s', map = {Array.NOARRAY: '%s',
Array.TUPLE: '(%s)', Array.TUPLE: '(%s)',
Array.LIST: '[%s]', Array.LIST: '[%s]',
Array.DICT: '{%s}', Array.DICT: '{%s}',
Array.SET: '{%s}' Array.SET: '{%s}'
} }
inner = [] inner = []
for i, value in enumerate(self.values): for i, value in enumerate(self.values):
@@ -1077,7 +1077,7 @@ class Name(Simple):
def __init__(self, names, start_pos, end_pos, parent=None): def __init__(self, names, start_pos, end_pos, parent=None):
super(Name, self).__init__(start_pos, end_pos) super(Name, self).__init__(start_pos, end_pos)
self.names = tuple(n if isinstance(n, NamePart) else NamePart(*n) self.names = tuple(n if isinstance(n, NamePart) else NamePart(*n)
for n in names) for n in names)
if parent is not None: if parent is not None:
self.parent = weakref.ref(parent) self.parent = weakref.ref(parent)
@@ -1484,7 +1484,7 @@ class PyFuzzyParser(object):
for t in toks: for t in toks:
src += t[1] if isinstance(t, tuple) \ src += t[1] if isinstance(t, tuple) \
else t.get_code() else t.get_code()
st = Statement(src, [], [], [], \ st = Statement(src, [], [], [],
toks, first_pos, self.end_pos) toks, first_pos, self.end_pos)
for s in [st, middle, in_clause]: for s in [st, middle, in_clause]:
@@ -1534,7 +1534,7 @@ class PyFuzzyParser(object):
self.scope.add_docstr(self.last_token[1]) self.scope.add_docstr(self.last_token[1])
return None, tok return None, tok
else: else:
stmt = stmt_class(string, set_vars, used_funcs, used_vars, \ stmt = stmt_class(string, set_vars, used_funcs, used_vars,
tok_list, first_pos, self.end_pos) tok_list, first_pos, self.end_pos)
self._check_user_stmt(stmt) self._check_user_stmt(stmt)
if is_return: if is_return: