1
0
forked from VimPlug/jedi

move default arguments [] to (), because mutable may be dangerous (especially in a recursive environment

This commit is contained in:
David Halter
2013-02-11 01:21:51 +01:00
parent f423de1956
commit 52b32a01c1
4 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -300,7 +300,7 @@ class Script(object):
definitions = [user_stmt] definitions = [user_stmt]
return definitions, search_name return definitions, search_name
def related_names(self, additional_module_paths=[]): def related_names(self, additional_module_paths=()):
""" """
Return :class:`api_classes.RelatedName` objects, which contain all Return :class:`api_classes.RelatedName` objects, which contain all
names that point to the definition of the name under the cursor. This names that point to the definition of the name under the cursor. This
+1 -1
View File
@@ -520,7 +520,7 @@ def assign_tuples(tup, results, seek_name):
@recursion.RecursionDecorator @recursion.RecursionDecorator
@cache.memoize_default(default=[]) @cache.memoize_default(default=())
def follow_statement(stmt, seek_name=None): def follow_statement(stmt, seek_name=None):
""" """
The starting point of the completion. A statement always owns a call list, The starting point of the completion. A statement always owns a call list,
+8 -8
View File
@@ -39,7 +39,7 @@ class Executable(pr.Base):
An instance is also an executable - because __init__ is called An instance is also an executable - because __init__ is called
:param var_args: The param input array, consist of `pr.Array` or list. :param var_args: The param input array, consist of `pr.Array` or list.
""" """
def __init__(self, base, var_args=[]): def __init__(self, base, var_args=()):
self.base = base self.base = base
self.var_args = var_args self.var_args = var_args
@@ -53,7 +53,7 @@ class Executable(pr.Base):
class Instance(use_metaclass(cache.CachedMetaClass, Executable)): class Instance(use_metaclass(cache.CachedMetaClass, Executable)):
""" This class is used to evaluate instances. """ """ This class is used to evaluate instances. """
def __init__(self, base, var_args=[]): def __init__(self, base, var_args=()):
super(Instance, self).__init__(base, var_args) super(Instance, self).__init__(base, var_args)
if str(base.name) in ['list', 'set'] \ if str(base.name) in ['list', 'set'] \
and builtin.Builtin.scope == base.get_parent_until(): and builtin.Builtin.scope == base.get_parent_until():
@@ -122,7 +122,7 @@ class Instance(use_metaclass(cache.CachedMetaClass, Executable)):
sub = self.base.get_subscope_by_name(name) sub = self.base.get_subscope_by_name(name)
return InstanceElement(self, sub, True) return InstanceElement(self, sub, True)
def execute_subscope_by_name(self, name, args=[]): def execute_subscope_by_name(self, name, args=()):
method = self.get_subscope_by_name(name) method = self.get_subscope_by_name(name)
return Execution(method, args).get_return_types() return Execution(method, args).get_return_types()
@@ -249,7 +249,7 @@ class Class(use_metaclass(cache.CachedMetaClass, pr.Base)):
def __init__(self, base): def __init__(self, base):
self.base = base self.base = base
@cache.memoize_default(default=[]) @cache.memoize_default(default=())
def get_super_classes(self): def get_super_classes(self):
supers = [] supers = []
# TODO care for mro stuff (multiple super classes). # TODO care for mro stuff (multiple super classes).
@@ -265,7 +265,7 @@ class Class(use_metaclass(cache.CachedMetaClass, pr.Base)):
supers += evaluate.find_name(builtin.Builtin.scope, 'object') supers += evaluate.find_name(builtin.Builtin.scope, 'object')
return supers return supers
@cache.memoize_default(default=[]) @cache.memoize_default(default=())
def get_defined_names(self): def get_defined_names(self):
def in_iterable(name, iterable): def in_iterable(name, iterable):
""" checks if the name is in the variable 'iterable'. """ """ checks if the name is in the variable 'iterable'. """
@@ -399,7 +399,7 @@ class Execution(Executable):
else: else:
return [stmt] # just some arbitrary object return [stmt] # just some arbitrary object
@cache.memoize_default(default=[]) @cache.memoize_default(default=())
@recursion.ExecutionRecursionDecorator @recursion.ExecutionRecursionDecorator
def get_return_types(self, evaluate_generator=False): def get_return_types(self, evaluate_generator=False):
""" Get the return types of a function. """ """ Get the return types of a function. """
@@ -490,7 +490,7 @@ class Execution(Executable):
stmts += evaluate.follow_statement(r) stmts += evaluate.follow_statement(r)
return stmts return stmts
@cache.memoize_default(default=[]) @cache.memoize_default(default=())
def get_params(self): def get_params(self):
""" """
This returns the params for an Execution/Instance and is injected as a This returns the params for an Execution/Instance and is injected as a
@@ -498,7 +498,7 @@ class Execution(Executable):
This needs to be here, because Instance can have __init__ functions, This needs to be here, because Instance can have __init__ functions,
which act the same way as normal functions. which act the same way as normal functions.
""" """
def gen_param_name_copy(param, keys=[], values=[], array_type=None): def gen_param_name_copy(param, keys=(), values=(), array_type=None):
""" """
Create a param with the original scope (of varargs) as parent. Create a param with the original scope (of varargs) as parent.
""" """
+1 -1
View File
@@ -318,7 +318,7 @@ def strip_imports(scopes):
@cache.cache_star_import @cache.cache_star_import
def remove_star_imports(scope, ignored_modules=[]): def remove_star_imports(scope, ignored_modules=()):
""" """
Check a module for star imports: Check a module for star imports:
>>> from module import * >>> from module import *