diff --git a/IPython/utils/tests/test_traitlets.py b/IPython/utils/tests/test_traitlets.py index 74278b7..feb462e 100644 --- a/IPython/utils/tests/test_traitlets.py +++ b/IPython/utils/tests/test_traitlets.py @@ -998,8 +998,8 @@ class TestInstanceList(TraitTestBase): self.assertIs(self.obj.traits()['value']._trait.klass, Foo) _default_value = [] - _good_values = [[Foo(), Foo(), None], None] - _bad_values = [['1', 2,], '1', [Foo]] + _good_values = [[Foo(), Foo(), None], []] + _bad_values = [['1', 2,], '1', [Foo], None] class UnionListTrait(HasTraits): @@ -1475,14 +1475,14 @@ class TestForwardDeclaredInstanceList(TraitTestBase): [ForwardDeclaredBar(), ForwardDeclaredBarSub(), None], [None], [], - None, ] _bad_values = [ ForwardDeclaredBar(), [ForwardDeclaredBar(), 3], '1', # Note that this is the type, not an instance. - [ForwardDeclaredBar] + [ForwardDeclaredBar], + None, ] class TestForwardDeclaredTypeList(TraitTestBase): @@ -1498,14 +1498,14 @@ class TestForwardDeclaredTypeList(TraitTestBase): [ForwardDeclaredBar, ForwardDeclaredBarSub, None], [], [None], - None, ] _bad_values = [ ForwardDeclaredBar, [ForwardDeclaredBar, 3], '1', # Note that this is an instance, not the type. - [ForwardDeclaredBar()] + [ForwardDeclaredBar()], + None, ] ### # End Forward Declaration Tests diff --git a/IPython/utils/traitlets.py b/IPython/utils/traitlets.py index 35ee687..a8b9bad 100644 --- a/IPython/utils/traitlets.py +++ b/IPython/utils/traitlets.py @@ -1340,9 +1340,9 @@ class CBool(Bool): class Enum(TraitType): """An enum that whose value must be in a given sequence.""" - def __init__(self, values, default_value=None, allow_none=True, **metadata): + def __init__(self, values, default_value=None, **metadata): self.values = values - super(Enum, self).__init__(default_value, allow_none=allow_none, **metadata) + super(Enum, self).__init__(default_value, **metadata) def validate(self, obj, value): if value in self.values: @@ -1378,7 +1378,7 @@ class Container(Instance): _valid_defaults = SequenceTypes _trait = None - def __init__(self, trait=None, default_value=None, allow_none=True, + def __init__(self, trait=None, default_value=None, allow_none=False, **metadata): """Create a container trait type from a list, set, or tuple. @@ -1474,8 +1474,7 @@ class List(Container): klass = list _cast_types = (tuple,) - def __init__(self, trait=None, default_value=None, minlen=0, maxlen=sys.maxsize, - allow_none=True, **metadata): + def __init__(self, trait=None, default_value=None, minlen=0, maxlen=sys.maxsize, **metadata): """Create a List trait type from a list, set, or tuple. The default value is created by doing ``List(default_value)``, @@ -1516,7 +1515,7 @@ class List(Container): self._minlen = minlen self._maxlen = maxlen super(List, self).__init__(trait=trait, default_value=default_value, - allow_none=allow_none, **metadata) + **metadata) def length_error(self, obj, value): e = "The '%s' trait of %s instance must be of length %i <= L <= %i, but a value of %s was specified." \ @@ -1550,7 +1549,7 @@ class Tuple(Container): _cast_types = (list,) def __init__(self, *traits, **metadata): - """Tuple(*traits, default_value=None, allow_none=True, **medatata) + """Tuple(*traits, default_value=None, **medatata) Create a tuple from a list, set, or tuple. @@ -1612,8 +1611,7 @@ class Tuple(Container): if self._traits and default_value is None: # don't allow default to be an empty container if length is specified args = None - super(Container,self).__init__(klass=self.klass, args=args, - allow_none=allow_none, **metadata) + super(Container,self).__init__(klass=self.klass, args=args, **metadata) def validate_elements(self, obj, value): if not self._traits: @@ -1646,7 +1644,7 @@ class Tuple(Container): class Dict(Instance): """An instance of a Python dict.""" - def __init__(self, default_value={}, allow_none=True, **metadata): + def __init__(self, default_value={}, allow_none=False, **metadata): """Create a dict trait type from a dict. The default value is created by doing ``dict(default_value)``, @@ -1668,7 +1666,7 @@ class Dict(Instance): class EventfulDict(Instance): """An instance of an EventfulDict.""" - def __init__(self, default_value={}, allow_none=True, **metadata): + def __init__(self, default_value={}, allow_none=False, **metadata): """Create a EventfulDict trait type from a dict. The default value is created by doing @@ -1691,7 +1689,7 @@ class EventfulDict(Instance): class EventfulList(Instance): """An instance of an EventfulList.""" - def __init__(self, default_value=None, allow_none=True, **metadata): + def __init__(self, default_value=None, allow_none=False, **metadata): """Create a EventfulList trait type from a dict. The default value is created by doing