cleaning / pep8

This commit is contained in:
David Halter
2012-08-23 14:45:29 +02:00
parent 793797ca5c
commit e28d7f0cdf
7 changed files with 14 additions and 13 deletions

View File

@@ -111,6 +111,7 @@ def search_params(param):
return result return result
def check_array_additions(array): def check_array_additions(array):
""" Just a mapper function for the internal _check_array_additions """ """ Just a mapper function for the internal _check_array_additions """
if array._array.type not in ['list', 'set']: if array._array.type not in ['list', 'set']:
@@ -187,7 +188,6 @@ def _check_array_additions(compare_array, module, is_list):
continue continue
ass = stmt.get_assignment_calls() ass = stmt.get_assignment_calls()
new_calls = scan_array(ass, add_name) new_calls = scan_array(ass, add_name)
#print [c.start_pos for c in new_calls], stmt.start_pos
result += check_calls(new_calls, add_name) result += check_calls(new_calls, add_name)
evaluate.follow_statement.pop_stmt() evaluate.follow_statement.pop_stmt()
continue continue

View File

@@ -927,7 +927,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
func = r.parent() func = r.parent()
# Instances are typically faked, if the instance is not # Instances are typically faked, if the instance is not
# called from outside. Here we check it for __init__ # called from outside. Here we check it for __init__
# functions and return # functions and return.
if isinstance(func, InstanceElement) \ if isinstance(func, InstanceElement) \
and func.instance.is_generated \ and func.instance.is_generated \
and str(func.name) == '__init__' \ and str(func.name) == '__init__' \
@@ -1177,8 +1177,6 @@ def follow_statement(stmt, seek_name=None):
# Assignment checking is only important if the statement defines multiple # Assignment checking is only important if the statement defines multiple
# variables. # variables.
if len(stmt.get_set_vars()) > 1 and seek_name and stmt.assignment_details: if len(stmt.get_set_vars()) > 1 and seek_name and stmt.assignment_details:
# TODO This should have its own call_list, because call_list can also
# return 3 results for 2 variables.
new_result = [] new_result = []
for op, set_vars in stmt.assignment_details: for op, set_vars in stmt.assignment_details:
new_result += assign_tuples(set_vars, result, seek_name) new_result += assign_tuples(set_vars, result, seek_name)

View File

@@ -75,7 +75,7 @@ class RecursionNode(object):
and self.position == other.position and not self.is_ignored and self.position == other.position and not self.is_ignored
def fast_parent_copy(obj): def fast_parent_copy_old(obj):
""" """
Much, much faster than deepcopy, but just for the elements in `classes`. Much, much faster than deepcopy, but just for the elements in `classes`.
""" """
@@ -107,12 +107,12 @@ def fast_parent_copy(obj):
return copied_list return copied_list
return recursion(obj) return recursion(obj)
def fast_parent_copy2(obj): def fast_parent_copy(obj):
""" """
Much, much faster than deepcopy, but just for the elements in `classes`. Much, much faster than deepcopy, but just for the elements in `classes`.
""" """
new_elements = {} new_elements = {}
classes = (parsing.Simple) classes = (parsing.Simple, parsing.Call)
def recursion(obj): def recursion(obj):
new_obj = copy.copy(obj) new_obj = copy.copy(obj)
@@ -141,11 +141,9 @@ def fast_parent_copy2(obj):
copied_list[i] = recursion(el) copied_list[i] = recursion(el)
elif isinstance(el, list): elif isinstance(el, list):
copied_list[i] = list_rec(el) copied_list[i] = list_rec(el)
elif isinstance(el, parsing.Call):
copied_list[i] = fast_parent_copy(el)
return copied_list return copied_list
return recursion(obj) return recursion(obj)
fast_parent_copy2 = fast_parent_copy
def generate_param_array(args_tuple, parent_stmt=None): def generate_param_array(args_tuple, parent_stmt=None):
""" This generates an array, that can be used as a param """ """ This generates an array, that can be used as a param """

View File

@@ -160,9 +160,9 @@ class frozenset():
#-------------------------------------------------------- #--------------------------------------------------------
class int(): class int():
def __init__(self, x, base=None): def __init__(self, x, base=None):
self.__x = x pass
class str(): class str():
def __init__(self, obj): def __init__(self, obj):
self.__obj = obj pass

View File

@@ -229,3 +229,7 @@ tuple(list(set(a)))[1]
tuple({1})[0] tuple({1})[0]
#? int() #? int()
tuple((1,))[0] tuple((1,))[0]
# implementation detail for lists, should not be visible
#? []
list().__iterable

View File

@@ -56,7 +56,7 @@ try:
#? str() #? str()
"" ""
# wrong ternary # wrong ternary expression
a = 1 if a = 1 if
#? int() #? int()
a a

View File

@@ -32,5 +32,6 @@ el = list(evaluate.get_names_for_scope(1))[0][1]
el = list(evaluate.get_names_for_scope())[0][1] el = list(evaluate.get_names_for_scope())[0][1]
# TODO here should stand evaluate.Instance() and so on. # TODO here should stand evaluate.Instance() and so on.
# need to understand list comprehensions
#? #?
el = list(evaluate.get_names_for_scope())[0][1][0] el = list(evaluate.get_names_for_scope())[0][1][0]