Permalink
Browse files

Merge pull request #37 from gwrtheyrn/refactorings

Trivial Refactorings
  • Loading branch information...
davidhalter committed Oct 21, 2012
2 parents bb76792 + c5b9eca commit 057f051d46c84cfbbdd026852c8d5326f3a63ada
Showing with 41 additions and 41 deletions.
  1. +1 −1 jedi/dynamic.py
  2. +1 −1 jedi/keywords.py
  3. +1 −1 jedi/modules.py
  4. +38 −38 jedi/parsing.py
View
@@ -542,7 +542,7 @@ def check_statement_information(stmt, search_name):
classes_call = isinst[1][0] # class_or_type_or_tuple
assert isinstance(classes_call, parsing.Call)
result = []
- for c in evaluate.follow_call(classes_call):
+ for c in evaluate.follow_call(classes_call):
if isinstance(c, evaluate.Array):
result += c.get_index_types()
else:
View
@@ -68,7 +68,7 @@ def imitate_pydoc(string):
pass
get_target = lambda s: h.topics.get(s, h.keywords.get(s))
- while type(string) == type(''):
+ while isinstance(string, str):
string = get_target(string)
try:
View
@@ -227,7 +227,7 @@ def check_module(module):
if call.execution is None:
continue
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):
continue
View
@@ -44,7 +44,7 @@ class ParserError(Exception):
pass
-def indent_block(text, indention=" "):
+def indent_block(text, indention=' '):
""" This function indents a text block with a default of four spaces """
temp = ''
while text and text[-1] == '\n':
@@ -176,7 +176,7 @@ def get_imports(self):
i += s.get_imports()
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.
:rtype: str
@@ -220,8 +220,8 @@ def get_set_vars(self):
return n
def get_defined_names(self):
- return [n for n in self.get_set_vars() \
- if isinstance(n, Import) or len(n) == 1]
+ return [n for n in self.get_set_vars()
+ if isinstance(n, Import) or len(n) == 1]
def is_empty(self):
"""
@@ -325,17 +325,17 @@ def __init__(self, name, supers, start_pos, docstr=''):
s.parent = weakref.ref(self)
self.decorators = []
- def get_code(self, first_indent=False, indention=" "):
- str = "\n".join('@' + stmt.get_code() for stmt in self.decorators)
- str += 'class %s' % (self.name)
+ def get_code(self, first_indent=False, indention=' '):
+ string = "\n".join('@' + stmt.get_code() for stmt in self.decorators)
+ string += 'class %s' % (self.name)
if len(self.supers) > 0:
sup = ','.join(stmt.code for stmt in self.supers)
- str += '(%s)' % sup
- str += ':\n'
- str += super(Class, self).get_code(True, indention)
+ string += '(%s)' % sup
+ string += ':\n'
+ string += super(Class, self).get_code(True, indention)
if self.is_empty():
- str += "pass\n"
- return str
+ string += "pass\n"
+ return string
class Function(Scope):
@@ -367,14 +367,14 @@ def __init__(self, name, params, start_pos, annotation):
annotation.parent = weakref.ref(self)
self.annotation = annotation
- def get_code(self, first_indent=False, indention=" "):
- str = "\n".join('@' + stmt.get_code() for stmt in self.decorators)
+ def get_code(self, first_indent=False, indention=' '):
+ string = "\n".join('@' + stmt.get_code() for stmt in self.decorators)
params = ','.join([stmt.code for stmt in self.params])
- str += "def %s(%s):\n" % (self.name, params)
- str += super(Function, self).get_code(True, indention)
+ string += "def %s(%s):\n" % (self.name, params)
+ string += super(Function, self).get_code(True, indention)
if self.is_empty():
- str += "pass\n"
- return str
+ string += "pass\n"
+ return string
def get_set_vars(self):
n = super(Function, self).get_set_vars()
@@ -418,7 +418,7 @@ def __init__(self, command, inits, start_pos, set_vars=None):
self.inits = inits
for s in inits:
s.parent = weakref.ref(self)
- if set_vars == None:
+ if set_vars is None:
self.set_vars = []
else:
self.set_vars = set_vars
@@ -436,16 +436,16 @@ def parent(self, value):
if self.next:
self.next.parent = value
- def get_code(self, first_indent=False, indention=" "):
+ def get_code(self, first_indent=False, indention=' '):
stmts = []
for s in self.inits:
stmts.append(s.get_code(new_line=False))
stmt = ', '.join(stmts)
- str = "%s %s:\n" % (self.command, vars, stmt)
- str += super(Flow, self).get_code(True, indention)
+ string = "%s %s:\n" % (self.command, vars, stmt)
+ string += super(Flow, self).get_code(True, indention)
if self.next:
- str += self.next.get_code()
- return str
+ string += self.next.get_code()
+ return string
def get_set_vars(self, is_internal_call=False):
"""
@@ -522,8 +522,8 @@ class Import(Simple):
:param defunct: An Import is valid or not.
:type defunct: bool
"""
- def __init__(self, start_pos, end_pos, namespace, alias=None, \
- from_ns=None, star=False, relative_count=0, defunct=False):
+ def __init__(self, start_pos, end_pos, namespace, alias=None,
+ from_ns=None, star=False, relative_count=0, defunct=False):
super(Import, self).__init__(start_pos, end_pos)
self.namespace = namespace
@@ -807,7 +807,7 @@ def get_assignment_calls(self):
if level != 0:
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 = top
@@ -819,10 +819,10 @@ class Param(Statement):
The class which shows definitions of params of classes and functions.
But this is not to define function calls.
"""
- def __init__(self, code, set_vars, used_funcs, used_vars, token_list,
- start_pos, end_pos):
- super(Param, self).__init__(code, set_vars, used_funcs,
- used_vars, token_list, start_pos, end_pos)
+ def __init__(self, code, set_vars, used_funcs, used_vars,
+ token_list, start_pos, end_pos):
+ super(Param, self).__init__(code, set_vars, used_funcs, used_vars,
+ token_list, start_pos, end_pos)
# this is defined by the parser later on, not at the initialization
# it is the position in the call (first argument, second...)
@@ -1024,10 +1024,10 @@ def to_str(el):
return str(el)
map = {Array.NOARRAY: '%s',
- Array.TUPLE: '(%s)',
- Array.LIST: '[%s]',
- Array.DICT: '{%s}',
- Array.SET: '{%s}'
+ Array.TUPLE: '(%s)',
+ Array.LIST: '[%s]',
+ Array.DICT: '{%s}',
+ Array.SET: '{%s}'
}
inner = []
for i, value in enumerate(self.values):
@@ -1077,7 +1077,7 @@ class Name(Simple):
def __init__(self, names, start_pos, end_pos, parent=None):
super(Name, self).__init__(start_pos, end_pos)
self.names = tuple(n if isinstance(n, NamePart) else NamePart(*n)
- for n in names)
+ for n in names)
if parent is not None:
self.parent = weakref.ref(parent)
@@ -1484,7 +1484,7 @@ def _parse_statement(self, pre_used_token=None, added_breaks=None,
for t in toks:
src += t[1] if isinstance(t, tuple) \
else t.get_code()
- st = Statement(src, [], [], [], \
+ st = Statement(src, [], [], [],
toks, first_pos, self.end_pos)
for s in [st, middle, in_clause]:
@@ -1534,7 +1534,7 @@ def _parse_statement(self, pre_used_token=None, added_breaks=None,
self.scope.add_docstr(self.last_token[1])
return None, tok
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)
self._check_user_stmt(stmt)
if is_return:

0 comments on commit 057f051

Please sign in to comment.