##// END OF EJS Templates
Merge pull request #7708 from SylvainCorlay/allow_none...
Min RK -
r20763:454aa2cb merge
parent child Browse files
Show More
@@ -173,15 +173,15 b' class InteractiveShellApp(Configurable):'
173 173 module_to_run = Unicode('', config=True,
174 174 help="Run the module as a script."
175 175 )
176 gui = CaselessStrEnum(gui_keys, config=True,
176 gui = CaselessStrEnum(gui_keys, config=True, allow_none=True,
177 177 help="Enable GUI event loop integration with any of {0}.".format(gui_keys)
178 178 )
179 matplotlib = CaselessStrEnum(backend_keys,
179 matplotlib = CaselessStrEnum(backend_keys, allow_none=True,
180 180 config=True,
181 181 help="""Configure matplotlib for interactive use with
182 182 the default matplotlib backend."""
183 183 )
184 pylab = CaselessStrEnum(backend_keys,
184 pylab = CaselessStrEnum(backend_keys, allow_none=True,
185 185 config=True,
186 186 help="""Pre-load matplotlib and numpy for interactive use,
187 187 selecting a particular matplotlib backend and loop integration.
@@ -109,7 +109,7 b' class ContentsManager(LoggingConfigurable):'
109 109
110 110 checkpoints_class = Type(Checkpoints, config=True)
111 111 checkpoints = Instance(Checkpoints, config=True)
112 checkpoints_kwargs = Dict(allow_none=False, config=True)
112 checkpoints_kwargs = Dict(config=True)
113 113
114 114 def _checkpoints_default(self):
115 115 return self.checkpoints_class(**self.checkpoints_kwargs)
@@ -140,7 +140,7 b' class Widget(LoggingConfigurable):'
140 140
141 141 _property_lock = Tuple((None, None))
142 142 _send_state_lock = Int(0)
143 _states_to_send = Set(allow_none=False)
143 _states_to_send = Set()
144 144 _display_callbacks = Instance(CallbackDispatcher, ())
145 145 _msg_callbacks = Instance(CallbackDispatcher, ())
146 146
@@ -18,16 +18,16 b' class Box(DOMWidget):'
18 18 # Child widgets in the container.
19 19 # Using a tuple here to force reassignment to update the list.
20 20 # When a proper notifying-list trait exists, that is what should be used here.
21 children = Tuple(sync=True, allow_none=False)
21 children = Tuple(sync=True)
22 22
23 23 _overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', '']
24 24 overflow_x = CaselessStrEnum(
25 25 values=_overflow_values,
26 default_value='', allow_none=False, sync=True, help="""Specifies what
26 default_value='', sync=True, help="""Specifies what
27 27 happens to content that is too large for the rendered region.""")
28 28 overflow_y = CaselessStrEnum(
29 29 values=_overflow_values,
30 default_value='', allow_none=False, sync=True, help="""Specifies what
30 default_value='', sync=True, help="""Specifies what
31 31 happens to content that is too large for the rendered region.""")
32 32
33 33 box_style = CaselessStrEnum(
@@ -59,10 +59,10 b' class FlexBox(Box):'
59 59 _locations = ['start', 'center', 'end', 'baseline', 'stretch']
60 60 pack = CaselessStrEnum(
61 61 values=_locations,
62 default_value='start', allow_none=False, sync=True)
62 default_value='start', sync=True)
63 63 align = CaselessStrEnum(
64 64 values=_locations,
65 default_value='start', allow_none=False, sync=True)
65 default_value='start', sync=True)
66 66
67 67
68 68 def VBox(*pargs, **kwargs):
@@ -130,8 +130,7 b' class FloatSlider(_BoundedFloat):'
130 130 """
131 131 _view_name = Unicode('FloatSliderView', sync=True)
132 132 orientation = CaselessStrEnum(values=['horizontal', 'vertical'],
133 default_value='horizontal',
134 help="Vertical or horizontal.", allow_none=False, sync=True)
133 default_value='horizontal', help="Vertical or horizontal.", sync=True)
135 134 _range = Bool(False, help="Display a range selector", sync=True)
136 135 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
137 136 slider_color = Unicode(sync=True)
@@ -285,8 +284,7 b' class FloatRangeSlider(_BoundedFloatRange):'
285 284 """
286 285 _view_name = Unicode('FloatSliderView', sync=True)
287 286 orientation = CaselessStrEnum(values=['horizontal', 'vertical'],
288 default_value='horizontal', allow_none=False,
289 help="Vertical or horizontal.", sync=True)
287 default_value='horizontal', help="Vertical or horizontal.", sync=True)
290 288 _range = Bool(True, help="Display a range selector", sync=True)
291 289 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
292 290 slider_color = Unicode(sync=True)
@@ -84,8 +84,7 b' class IntSlider(_BoundedInt):'
84 84 """Slider widget that represents a int bounded by a minimum and maximum value."""
85 85 _view_name = Unicode('IntSliderView', sync=True)
86 86 orientation = CaselessStrEnum(values=['horizontal', 'vertical'],
87 default_value='horizontal', allow_none=False,
88 help="Vertical or horizontal.", sync=True)
87 default_value='horizontal', help="Vertical or horizontal.", sync=True)
89 88 _range = Bool(False, help="Display a range selector", sync=True)
90 89 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
91 90 slider_color = Unicode(sync=True)
@@ -196,8 +195,7 b' class IntRangeSlider(_BoundedIntRange):'
196 195 """Slider widget that represents a pair of ints between a minimum and maximum value."""
197 196 _view_name = Unicode('IntSliderView', sync=True)
198 197 orientation = CaselessStrEnum(values=['horizontal', 'vertical'],
199 default_value='horizontal', allow_none=False,
200 help="Vertical or horizontal.", sync=True)
198 default_value='horizontal', help="Vertical or horizontal.", sync=True)
201 199 _range = Bool(True, help="Display a range selector", sync=True)
202 200 readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
203 201 slider_color = Unicode(sync=True)
@@ -106,7 +106,7 b' class MimeBundle(Reference):'
106 106
107 107 class ExecuteReply(Reference):
108 108 execution_count = Integer()
109 status = Enum((u'ok', u'error'))
109 status = Enum((u'ok', u'error'), default_value=u'ok')
110 110
111 111 def check(self, d):
112 112 Reference.check(self, d)
@@ -139,7 +139,7 b' class ArgSpec(Reference):'
139 139
140 140
141 141 class Status(Reference):
142 execution_state = Enum((u'busy', u'idle', u'starting'))
142 execution_state = Enum((u'busy', u'idle', u'starting'), default_value=u'busy')
143 143
144 144
145 145 class CompleteReply(Reference):
@@ -165,7 +165,7 b' class KernelInfoReply(Reference):'
165 165
166 166
167 167 class IsCompleteReply(Reference):
168 status = Enum((u'complete', u'incomplete', u'invalid', u'unknown'))
168 status = Enum((u'complete', u'incomplete', u'invalid', u'unknown'), default_value=u'complete')
169 169
170 170 def check(self, d):
171 171 Reference.check(self, d)
@@ -187,7 +187,7 b' Error = ExecuteReplyError'
187 187
188 188
189 189 class Stream(Reference):
190 name = Enum((u'stdout', u'stderr'))
190 name = Enum((u'stdout', u'stderr'), default_value=u'stdout')
191 191 text = Unicode()
192 192
193 193
@@ -171,8 +171,8 b' class TaskScheduler(SessionFactory):'
171 171 """
172 172 )
173 173 scheme_name = Enum(('leastload', 'pure', 'lru', 'plainrandom', 'weighted', 'twobin'),
174 'leastload', config=True, allow_none=False,
175 help="""select the task scheduler scheme [default: Python LRU]
174 'leastload', config=True,
175 help="""select the task scheduler scheme [default: Python LRU]
176 176 Options are: 'pure', 'lru', 'plainrandom', 'weighted', 'twobin','leastload'"""
177 177 )
178 178 def _scheme_name_changed(self, old, new):
@@ -50,7 +50,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
50 50 )
51 51
52 52 image_handler = Enum(('PIL', 'stream', 'tempfile', 'callable'),
53 config=True, help=
53 config=True, allow_none=True, help=
54 54 """
55 55 Handler for image type output. This is useful, for example,
56 56 when connecting to the kernel in which pylab inline backend is
@@ -99,7 +99,7 b' class ZMQTerminalInteractiveShell(TerminalInteractiveShell):'
99 99
100 100 mime_preference = List(
101 101 default_value=['image/png', 'image/jpeg', 'image/svg+xml'],
102 config=True, allow_none=False, help=
102 config=True, help=
103 103 """
104 104 Preferred object representation MIME type in order. First
105 105 matched MIME type will be used.
@@ -976,8 +976,8 b' class TestInstanceList(TraitTestBase):'
976 976 self.assertIs(self.obj.traits()['value']._trait.klass, Foo)
977 977
978 978 _default_value = []
979 _good_values = [[Foo(), Foo(), None], None]
980 _bad_values = [['1', 2,], '1', [Foo]]
979 _good_values = [[Foo(), Foo(), None], []]
980 _bad_values = [['1', 2,], '1', [Foo], None]
981 981
982 982 class LenListTrait(HasTraits):
983 983
@@ -1431,14 +1431,14 b' class TestForwardDeclaredInstanceList(TraitTestBase):'
1431 1431 [ForwardDeclaredBar(), ForwardDeclaredBarSub(), None],
1432 1432 [None],
1433 1433 [],
1434 None,
1435 1434 ]
1436 1435 _bad_values = [
1437 1436 ForwardDeclaredBar(),
1438 1437 [ForwardDeclaredBar(), 3],
1439 1438 '1',
1440 1439 # Note that this is the type, not an instance.
1441 [ForwardDeclaredBar]
1440 [ForwardDeclaredBar],
1441 None,
1442 1442 ]
1443 1443
1444 1444 class TestForwardDeclaredTypeList(TraitTestBase):
@@ -1454,14 +1454,14 b' class TestForwardDeclaredTypeList(TraitTestBase):'
1454 1454 [ForwardDeclaredBar, ForwardDeclaredBarSub, None],
1455 1455 [],
1456 1456 [None],
1457 None,
1458 1457 ]
1459 1458 _bad_values = [
1460 1459 ForwardDeclaredBar,
1461 1460 [ForwardDeclaredBar, 3],
1462 1461 '1',
1463 1462 # Note that this is an instance, not the type.
1464 [ForwardDeclaredBar()]
1463 [ForwardDeclaredBar()],
1464 None,
1465 1465 ]
1466 1466 ###
1467 1467 # End Forward Declaration Tests
@@ -815,7 +815,7 b' class Type(ClassBasedTraitType):'
815 815 may be specified in a string like: 'foo.bar.MyClass'.
816 816 The string is resolved into real class, when the parent
817 817 :class:`HasTraits` class is instantiated.
818 allow_none : boolean
818 allow_none : bool [ default True ]
819 819 Indicates whether None is allowed as an assignable value. Even if
820 820 ``False``, the default value may be ``None``.
821 821 """
@@ -912,7 +912,7 b' class Instance(ClassBasedTraitType):'
912 912 Positional arguments for generating the default value.
913 913 kw : dict
914 914 Keyword arguments for generating the default value.
915 allow_none : bool
915 allow_none : bool [default True]
916 916 Indicates whether None is allowed as a value.
917 917
918 918 Notes
@@ -1334,9 +1334,9 b' class CBool(Bool):'
1334 1334 class Enum(TraitType):
1335 1335 """An enum that whose value must be in a given sequence."""
1336 1336
1337 def __init__(self, values, default_value=None, allow_none=True, **metadata):
1337 def __init__(self, values, default_value=None, **metadata):
1338 1338 self.values = values
1339 super(Enum, self).__init__(default_value, allow_none=allow_none, **metadata)
1339 super(Enum, self).__init__(default_value, **metadata)
1340 1340
1341 1341 def validate(self, obj, value):
1342 1342 if value in self.values:
@@ -1372,7 +1372,7 b' class Container(Instance):'
1372 1372 _valid_defaults = SequenceTypes
1373 1373 _trait = None
1374 1374
1375 def __init__(self, trait=None, default_value=None, allow_none=True,
1375 def __init__(self, trait=None, default_value=None, allow_none=False,
1376 1376 **metadata):
1377 1377 """Create a container trait type from a list, set, or tuple.
1378 1378
@@ -1398,7 +1398,7 b' class Container(Instance):'
1398 1398 The default value for the Trait. Must be list/tuple/set, and
1399 1399 will be cast to the container type.
1400 1400
1401 allow_none : Bool [ default True ]
1401 allow_none : bool [ default False ]
1402 1402 Whether to allow the value to be None
1403 1403
1404 1404 **metadata : any
@@ -1468,8 +1468,7 b' class List(Container):'
1468 1468 klass = list
1469 1469 _cast_types = (tuple,)
1470 1470
1471 def __init__(self, trait=None, default_value=None, minlen=0, maxlen=sys.maxsize,
1472 allow_none=True, **metadata):
1471 def __init__(self, trait=None, default_value=None, minlen=0, maxlen=sys.maxsize, **metadata):
1473 1472 """Create a List trait type from a list, set, or tuple.
1474 1473
1475 1474 The default value is created by doing ``List(default_value)``,
@@ -1500,7 +1499,7 b' class List(Container):'
1500 1499 maxlen : Int [ default sys.maxsize ]
1501 1500 The maximum length of the input list
1502 1501
1503 allow_none : Bool [ default True ]
1502 allow_none : bool [ default False ]
1504 1503 Whether to allow the value to be None
1505 1504
1506 1505 **metadata : any
@@ -1510,7 +1509,7 b' class List(Container):'
1510 1509 self._minlen = minlen
1511 1510 self._maxlen = maxlen
1512 1511 super(List, self).__init__(trait=trait, default_value=default_value,
1513 allow_none=allow_none, **metadata)
1512 **metadata)
1514 1513
1515 1514 def length_error(self, obj, value):
1516 1515 e = "The '%s' trait of %s instance must be of length %i <= L <= %i, but a value of %s was specified." \
@@ -1544,7 +1543,7 b' class Tuple(Container):'
1544 1543 _cast_types = (list,)
1545 1544
1546 1545 def __init__(self, *traits, **metadata):
1547 """Tuple(*traits, default_value=None, allow_none=True, **medatata)
1546 """Tuple(*traits, default_value=None, **medatata)
1548 1547
1549 1548 Create a tuple from a list, set, or tuple.
1550 1549
@@ -1575,7 +1574,7 b' class Tuple(Container):'
1575 1574 will be cast to a tuple. If `traits` are specified, the
1576 1575 `default_value` must conform to the shape and type they specify.
1577 1576
1578 allow_none : Bool [ default True ]
1577 allow_none : bool [ default False ]
1579 1578 Whether to allow the value to be None
1580 1579
1581 1580 **metadata : any
@@ -1606,8 +1605,7 b' class Tuple(Container):'
1606 1605 if self._traits and default_value is None:
1607 1606 # don't allow default to be an empty container if length is specified
1608 1607 args = None
1609 super(Container,self).__init__(klass=self.klass, args=args,
1610 allow_none=allow_none, **metadata)
1608 super(Container,self).__init__(klass=self.klass, args=args, **metadata)
1611 1609
1612 1610 def validate_elements(self, obj, value):
1613 1611 if not self._traits:
@@ -1640,7 +1638,7 b' class Tuple(Container):'
1640 1638 class Dict(Instance):
1641 1639 """An instance of a Python dict."""
1642 1640
1643 def __init__(self, default_value={}, allow_none=True, **metadata):
1641 def __init__(self, default_value={}, allow_none=False, **metadata):
1644 1642 """Create a dict trait type from a dict.
1645 1643
1646 1644 The default value is created by doing ``dict(default_value)``,
@@ -1662,7 +1660,7 b' class Dict(Instance):'
1662 1660 class EventfulDict(Instance):
1663 1661 """An instance of an EventfulDict."""
1664 1662
1665 def __init__(self, default_value={}, allow_none=True, **metadata):
1663 def __init__(self, default_value={}, allow_none=False, **metadata):
1666 1664 """Create a EventfulDict trait type from a dict.
1667 1665
1668 1666 The default value is created by doing
@@ -1685,7 +1683,7 b' class EventfulDict(Instance):'
1685 1683 class EventfulList(Instance):
1686 1684 """An instance of an EventfulList."""
1687 1685
1688 def __init__(self, default_value=None, allow_none=True, **metadata):
1686 def __init__(self, default_value=None, allow_none=False, **metadata):
1689 1687 """Create a EventfulList trait type from a dict.
1690 1688
1691 1689 The default value is created by doing
General Comments 0
You need to be logged in to leave comments. Login now