##// END OF EJS Templates
allow_none=False for all trait types but Instance and Type
Sylvain Corlay -
Show More
@@ -998,8 +998,8 b' class TestInstanceList(TraitTestBase):'
998 998 self.assertIs(self.obj.traits()['value']._trait.klass, Foo)
999 999
1000 1000 _default_value = []
1001 _good_values = [[Foo(), Foo(), None], None]
1002 _bad_values = [['1', 2,], '1', [Foo]]
1001 _good_values = [[Foo(), Foo(), None], []]
1002 _bad_values = [['1', 2,], '1', [Foo], None]
1003 1003
1004 1004 class UnionListTrait(HasTraits):
1005 1005
@@ -1475,14 +1475,14 b' class TestForwardDeclaredInstanceList(TraitTestBase):'
1475 1475 [ForwardDeclaredBar(), ForwardDeclaredBarSub(), None],
1476 1476 [None],
1477 1477 [],
1478 None,
1479 1478 ]
1480 1479 _bad_values = [
1481 1480 ForwardDeclaredBar(),
1482 1481 [ForwardDeclaredBar(), 3],
1483 1482 '1',
1484 1483 # Note that this is the type, not an instance.
1485 [ForwardDeclaredBar]
1484 [ForwardDeclaredBar],
1485 None,
1486 1486 ]
1487 1487
1488 1488 class TestForwardDeclaredTypeList(TraitTestBase):
@@ -1498,14 +1498,14 b' class TestForwardDeclaredTypeList(TraitTestBase):'
1498 1498 [ForwardDeclaredBar, ForwardDeclaredBarSub, None],
1499 1499 [],
1500 1500 [None],
1501 None,
1502 1501 ]
1503 1502 _bad_values = [
1504 1503 ForwardDeclaredBar,
1505 1504 [ForwardDeclaredBar, 3],
1506 1505 '1',
1507 1506 # Note that this is an instance, not the type.
1508 [ForwardDeclaredBar()]
1507 [ForwardDeclaredBar()],
1508 None,
1509 1509 ]
1510 1510 ###
1511 1511 # End Forward Declaration Tests
@@ -1340,9 +1340,9 b' class CBool(Bool):'
1340 1340 class Enum(TraitType):
1341 1341 """An enum that whose value must be in a given sequence."""
1342 1342
1343 def __init__(self, values, default_value=None, allow_none=True, **metadata):
1343 def __init__(self, values, default_value=None, **metadata):
1344 1344 self.values = values
1345 super(Enum, self).__init__(default_value, allow_none=allow_none, **metadata)
1345 super(Enum, self).__init__(default_value, **metadata)
1346 1346
1347 1347 def validate(self, obj, value):
1348 1348 if value in self.values:
@@ -1378,7 +1378,7 b' class Container(Instance):'
1378 1378 _valid_defaults = SequenceTypes
1379 1379 _trait = None
1380 1380
1381 def __init__(self, trait=None, default_value=None, allow_none=True,
1381 def __init__(self, trait=None, default_value=None, allow_none=False,
1382 1382 **metadata):
1383 1383 """Create a container trait type from a list, set, or tuple.
1384 1384
@@ -1474,8 +1474,7 b' class List(Container):'
1474 1474 klass = list
1475 1475 _cast_types = (tuple,)
1476 1476
1477 def __init__(self, trait=None, default_value=None, minlen=0, maxlen=sys.maxsize,
1478 allow_none=True, **metadata):
1477 def __init__(self, trait=None, default_value=None, minlen=0, maxlen=sys.maxsize, **metadata):
1479 1478 """Create a List trait type from a list, set, or tuple.
1480 1479
1481 1480 The default value is created by doing ``List(default_value)``,
@@ -1516,7 +1515,7 b' class List(Container):'
1516 1515 self._minlen = minlen
1517 1516 self._maxlen = maxlen
1518 1517 super(List, self).__init__(trait=trait, default_value=default_value,
1519 allow_none=allow_none, **metadata)
1518 **metadata)
1520 1519
1521 1520 def length_error(self, obj, value):
1522 1521 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 b' class Tuple(Container):'
1550 1549 _cast_types = (list,)
1551 1550
1552 1551 def __init__(self, *traits, **metadata):
1553 """Tuple(*traits, default_value=None, allow_none=True, **medatata)
1552 """Tuple(*traits, default_value=None, **medatata)
1554 1553
1555 1554 Create a tuple from a list, set, or tuple.
1556 1555
@@ -1612,8 +1611,7 b' class Tuple(Container):'
1612 1611 if self._traits and default_value is None:
1613 1612 # don't allow default to be an empty container if length is specified
1614 1613 args = None
1615 super(Container,self).__init__(klass=self.klass, args=args,
1616 allow_none=allow_none, **metadata)
1614 super(Container,self).__init__(klass=self.klass, args=args, **metadata)
1617 1615
1618 1616 def validate_elements(self, obj, value):
1619 1617 if not self._traits:
@@ -1646,7 +1644,7 b' class Tuple(Container):'
1646 1644 class Dict(Instance):
1647 1645 """An instance of a Python dict."""
1648 1646
1649 def __init__(self, default_value={}, allow_none=True, **metadata):
1647 def __init__(self, default_value={}, allow_none=False, **metadata):
1650 1648 """Create a dict trait type from a dict.
1651 1649
1652 1650 The default value is created by doing ``dict(default_value)``,
@@ -1668,7 +1666,7 b' class Dict(Instance):'
1668 1666 class EventfulDict(Instance):
1669 1667 """An instance of an EventfulDict."""
1670 1668
1671 def __init__(self, default_value={}, allow_none=True, **metadata):
1669 def __init__(self, default_value={}, allow_none=False, **metadata):
1672 1670 """Create a EventfulDict trait type from a dict.
1673 1671
1674 1672 The default value is created by doing
@@ -1691,7 +1689,7 b' class EventfulDict(Instance):'
1691 1689 class EventfulList(Instance):
1692 1690 """An instance of an EventfulList."""
1693 1691
1694 def __init__(self, default_value=None, allow_none=True, **metadata):
1692 def __init__(self, default_value=None, allow_none=False, **metadata):
1695 1693 """Create a EventfulList trait type from a dict.
1696 1694
1697 1695 The default value is created by doing
General Comments 0
You need to be logged in to leave comments. Login now