Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 454aa2c

Browse files
committed
Merge pull request #7708 from SylvainCorlay/allow_none
allow_none=False for all trait types but Instance and Type
2 parents d532b15 + 7b48507 commit 454aa2c

11 files changed

Lines changed: 43 additions & 49 deletions

File tree

IPython/core/shellapp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ class InteractiveShellApp(Configurable):
173173
module_to_run = Unicode('', config=True,
174174
help="Run the module as a script."
175175
)
176-
gui = CaselessStrEnum(gui_keys, config=True,
176+
gui = CaselessStrEnum(gui_keys, config=True, allow_none=True,
177177
help="Enable GUI event loop integration with any of {0}.".format(gui_keys)
178178
)
179-
matplotlib = CaselessStrEnum(backend_keys,
179+
matplotlib = CaselessStrEnum(backend_keys, allow_none=True,
180180
config=True,
181181
help="""Configure matplotlib for interactive use with
182182
the default matplotlib backend."""
183183
)
184-
pylab = CaselessStrEnum(backend_keys,
184+
pylab = CaselessStrEnum(backend_keys, allow_none=True,
185185
config=True,
186186
help="""Pre-load matplotlib and numpy for interactive use,
187187
selecting a particular matplotlib backend and loop integration.

IPython/html/services/contents/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def run_pre_save_hook(self, model, path, **kwargs):
109109

110110
checkpoints_class = Type(Checkpoints, config=True)
111111
checkpoints = Instance(Checkpoints, config=True)
112-
checkpoints_kwargs = Dict(allow_none=False, config=True)
112+
checkpoints_kwargs = Dict(config=True)
113113

114114
def _checkpoints_default(self):
115115
return self.checkpoints_class(**self.checkpoints_kwargs)

IPython/html/widgets/widget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def _keys_default(self):
140140

141141
_property_lock = Tuple((None, None))
142142
_send_state_lock = Int(0)
143-
_states_to_send = Set(allow_none=False)
143+
_states_to_send = Set()
144144
_display_callbacks = Instance(CallbackDispatcher, ())
145145
_msg_callbacks = Instance(CallbackDispatcher, ())
146146

IPython/html/widgets/widget_box.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ class Box(DOMWidget):
1818
# Child widgets in the container.
1919
# Using a tuple here to force reassignment to update the list.
2020
# 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)
2222

2323
_overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', '']
2424
overflow_x = CaselessStrEnum(
2525
values=_overflow_values,
26-
default_value='', allow_none=False, sync=True, help="""Specifies what
26+
default_value='', sync=True, help="""Specifies what
2727
happens to content that is too large for the rendered region.""")
2828
overflow_y = CaselessStrEnum(
2929
values=_overflow_values,
30-
default_value='', allow_none=False, sync=True, help="""Specifies what
30+
default_value='', sync=True, help="""Specifies what
3131
happens to content that is too large for the rendered region.""")
3232

3333
box_style = CaselessStrEnum(
@@ -59,10 +59,10 @@ def _flex_changed(self, name, old, new):
5959
_locations = ['start', 'center', 'end', 'baseline', 'stretch']
6060
pack = CaselessStrEnum(
6161
values=_locations,
62-
default_value='start', allow_none=False, sync=True)
62+
default_value='start', sync=True)
6363
align = CaselessStrEnum(
6464
values=_locations,
65-
default_value='start', allow_none=False, sync=True)
65+
default_value='start', sync=True)
6666

6767

6868
def VBox(*pargs, **kwargs):

IPython/html/widgets/widget_float.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ class FloatSlider(_BoundedFloat):
130130
"""
131131
_view_name = Unicode('FloatSliderView', sync=True)
132132
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)
135134
_range = Bool(False, help="Display a range selector", sync=True)
136135
readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
137136
slider_color = Unicode(sync=True)
@@ -285,8 +284,7 @@ class FloatRangeSlider(_BoundedFloatRange):
285284
"""
286285
_view_name = Unicode('FloatSliderView', sync=True)
287286
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)
290288
_range = Bool(True, help="Display a range selector", sync=True)
291289
readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
292290
slider_color = Unicode(sync=True)

IPython/html/widgets/widget_int.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class IntSlider(_BoundedInt):
8484
"""Slider widget that represents a int bounded by a minimum and maximum value."""
8585
_view_name = Unicode('IntSliderView', sync=True)
8686
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)
8988
_range = Bool(False, help="Display a range selector", sync=True)
9089
readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
9190
slider_color = Unicode(sync=True)
@@ -196,8 +195,7 @@ class IntRangeSlider(_BoundedIntRange):
196195
"""Slider widget that represents a pair of ints between a minimum and maximum value."""
197196
_view_name = Unicode('IntSliderView', sync=True)
198197
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)
201199
_range = Bool(True, help="Display a range selector", sync=True)
202200
readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
203201
slider_color = Unicode(sync=True)

IPython/kernel/tests/test_message_spec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _data_changed(self, name, old, new):
106106

107107
class ExecuteReply(Reference):
108108
execution_count = Integer()
109-
status = Enum((u'ok', u'error'))
109+
status = Enum((u'ok', u'error'), default_value=u'ok')
110110

111111
def check(self, d):
112112
Reference.check(self, d)
@@ -139,7 +139,7 @@ class ArgSpec(Reference):
139139

140140

141141
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')
143143

144144

145145
class CompleteReply(Reference):
@@ -165,7 +165,7 @@ def check(self, d):
165165

166166

167167
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')
169169

170170
def check(self, d):
171171
Reference.check(self, d)
@@ -187,7 +187,7 @@ class ExecuteInput(Reference):
187187

188188

189189
class Stream(Reference):
190-
name = Enum((u'stdout', u'stderr'))
190+
name = Enum((u'stdout', u'stderr'), default_value=u'stdout')
191191
text = Unicode()
192192

193193

IPython/parallel/controller/scheduler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ class TaskScheduler(SessionFactory):
171171
"""
172172
)
173173
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]
176176
Options are: 'pure', 'lru', 'plainrandom', 'weighted', 'twobin','leastload'"""
177177
)
178178
def _scheme_name_changed(self, old, new):

IPython/terminal/console/interactiveshell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ZMQTerminalInteractiveShell(TerminalInteractiveShell):
5050
)
5151

5252
image_handler = Enum(('PIL', 'stream', 'tempfile', 'callable'),
53-
config=True, help=
53+
config=True, allow_none=True, help=
5454
"""
5555
Handler for image type output. This is useful, for example,
5656
when connecting to the kernel in which pylab inline backend is
@@ -99,7 +99,7 @@ class ZMQTerminalInteractiveShell(TerminalInteractiveShell):
9999

100100
mime_preference = List(
101101
default_value=['image/png', 'image/jpeg', 'image/svg+xml'],
102-
config=True, allow_none=False, help=
102+
config=True, help=
103103
"""
104104
Preferred object representation MIME type in order. First
105105
matched MIME type will be used.

IPython/utils/tests/test_traitlets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,8 @@ def test_klass(self):
976976
self.assertIs(self.obj.traits()['value']._trait.klass, Foo)
977977

978978
_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]
981981

982982
class LenListTrait(HasTraits):
983983

@@ -1431,14 +1431,14 @@ def test_klass(self):
14311431
[ForwardDeclaredBar(), ForwardDeclaredBarSub(), None],
14321432
[None],
14331433
[],
1434-
None,
14351434
]
14361435
_bad_values = [
14371436
ForwardDeclaredBar(),
14381437
[ForwardDeclaredBar(), 3],
14391438
'1',
14401439
# Note that this is the type, not an instance.
1441-
[ForwardDeclaredBar]
1440+
[ForwardDeclaredBar],
1441+
None,
14421442
]
14431443

14441444
class TestForwardDeclaredTypeList(TraitTestBase):
@@ -1454,14 +1454,14 @@ def test_klass(self):
14541454
[ForwardDeclaredBar, ForwardDeclaredBarSub, None],
14551455
[],
14561456
[None],
1457-
None,
14581457
]
14591458
_bad_values = [
14601459
ForwardDeclaredBar,
14611460
[ForwardDeclaredBar, 3],
14621461
'1',
14631462
# Note that this is an instance, not the type.
1464-
[ForwardDeclaredBar()]
1463+
[ForwardDeclaredBar()],
1464+
None,
14651465
]
14661466
###
14671467
# End Forward Declaration Tests

0 commit comments

Comments
 (0)