diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py index adb9b40..669febf 100644 --- a/IPython/core/shellapp.py +++ b/IPython/core/shellapp.py @@ -173,15 +173,15 @@ class InteractiveShellApp(Configurable): module_to_run = Unicode('', config=True, help="Run the module as a script." ) - gui = CaselessStrEnum(gui_keys, config=True, + gui = CaselessStrEnum(gui_keys, config=True, allow_none=True, help="Enable GUI event loop integration with any of {0}.".format(gui_keys) ) - matplotlib = CaselessStrEnum(backend_keys, + matplotlib = CaselessStrEnum(backend_keys, allow_none=True, config=True, help="""Configure matplotlib for interactive use with the default matplotlib backend.""" ) - pylab = CaselessStrEnum(backend_keys, + pylab = CaselessStrEnum(backend_keys, allow_none=True, config=True, help="""Pre-load matplotlib and numpy for interactive use, selecting a particular matplotlib backend and loop integration. diff --git a/IPython/html/services/contents/manager.py b/IPython/html/services/contents/manager.py index 446aed6..3f2e2a2 100644 --- a/IPython/html/services/contents/manager.py +++ b/IPython/html/services/contents/manager.py @@ -109,7 +109,7 @@ class ContentsManager(LoggingConfigurable): checkpoints_class = Type(Checkpoints, config=True) checkpoints = Instance(Checkpoints, config=True) - checkpoints_kwargs = Dict(allow_none=False, config=True) + checkpoints_kwargs = Dict(config=True) def _checkpoints_default(self): return self.checkpoints_class(**self.checkpoints_kwargs) diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index 062b671..50d9b90 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -140,7 +140,7 @@ class Widget(LoggingConfigurable): _property_lock = Tuple((None, None)) _send_state_lock = Int(0) - _states_to_send = Set(allow_none=False) + _states_to_send = Set() _display_callbacks = Instance(CallbackDispatcher, ()) _msg_callbacks = Instance(CallbackDispatcher, ()) diff --git a/IPython/html/widgets/widget_box.py b/IPython/html/widgets/widget_box.py index 555db22..ca73e0d 100644 --- a/IPython/html/widgets/widget_box.py +++ b/IPython/html/widgets/widget_box.py @@ -18,16 +18,16 @@ class Box(DOMWidget): # Child widgets in the container. # Using a tuple here to force reassignment to update the list. # When a proper notifying-list trait exists, that is what should be used here. - children = Tuple(sync=True, allow_none=False) + children = Tuple(sync=True) _overflow_values = ['visible', 'hidden', 'scroll', 'auto', 'initial', 'inherit', ''] overflow_x = CaselessStrEnum( values=_overflow_values, - default_value='', allow_none=False, sync=True, help="""Specifies what + default_value='', sync=True, help="""Specifies what happens to content that is too large for the rendered region.""") overflow_y = CaselessStrEnum( values=_overflow_values, - default_value='', allow_none=False, sync=True, help="""Specifies what + default_value='', sync=True, help="""Specifies what happens to content that is too large for the rendered region.""") box_style = CaselessStrEnum( @@ -59,10 +59,10 @@ class FlexBox(Box): _locations = ['start', 'center', 'end', 'baseline', 'stretch'] pack = CaselessStrEnum( values=_locations, - default_value='start', allow_none=False, sync=True) + default_value='start', sync=True) align = CaselessStrEnum( values=_locations, - default_value='start', allow_none=False, sync=True) + default_value='start', sync=True) def VBox(*pargs, **kwargs): diff --git a/IPython/html/widgets/widget_float.py b/IPython/html/widgets/widget_float.py index a25f568..47f6951 100644 --- a/IPython/html/widgets/widget_float.py +++ b/IPython/html/widgets/widget_float.py @@ -130,8 +130,7 @@ class FloatSlider(_BoundedFloat): """ _view_name = Unicode('FloatSliderView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], - default_value='horizontal', - help="Vertical or horizontal.", allow_none=False, sync=True) + default_value='horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(False, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) slider_color = Unicode(sync=True) @@ -285,8 +284,7 @@ class FloatRangeSlider(_BoundedFloatRange): """ _view_name = Unicode('FloatSliderView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], - default_value='horizontal', allow_none=False, - help="Vertical or horizontal.", sync=True) + default_value='horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(True, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) slider_color = Unicode(sync=True) diff --git a/IPython/html/widgets/widget_int.py b/IPython/html/widgets/widget_int.py index 4913ac1..c455615 100644 --- a/IPython/html/widgets/widget_int.py +++ b/IPython/html/widgets/widget_int.py @@ -84,8 +84,7 @@ class IntSlider(_BoundedInt): """Slider widget that represents a int bounded by a minimum and maximum value.""" _view_name = Unicode('IntSliderView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], - default_value='horizontal', allow_none=False, - help="Vertical or horizontal.", sync=True) + default_value='horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(False, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) slider_color = Unicode(sync=True) @@ -196,8 +195,7 @@ class IntRangeSlider(_BoundedIntRange): """Slider widget that represents a pair of ints between a minimum and maximum value.""" _view_name = Unicode('IntSliderView', sync=True) orientation = CaselessStrEnum(values=['horizontal', 'vertical'], - default_value='horizontal', allow_none=False, - help="Vertical or horizontal.", sync=True) + default_value='horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(True, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True) slider_color = Unicode(sync=True) diff --git a/IPython/kernel/tests/test_message_spec.py b/IPython/kernel/tests/test_message_spec.py index 3dabcc4..9e8f21b 100644 --- a/IPython/kernel/tests/test_message_spec.py +++ b/IPython/kernel/tests/test_message_spec.py @@ -106,7 +106,7 @@ class MimeBundle(Reference): class ExecuteReply(Reference): execution_count = Integer() - status = Enum((u'ok', u'error')) + status = Enum((u'ok', u'error'), default_value=u'ok') def check(self, d): Reference.check(self, d) @@ -139,7 +139,7 @@ class ArgSpec(Reference): class Status(Reference): - execution_state = Enum((u'busy', u'idle', u'starting')) + execution_state = Enum((u'busy', u'idle', u'starting'), default_value=u'busy') class CompleteReply(Reference): @@ -165,7 +165,7 @@ class KernelInfoReply(Reference): class IsCompleteReply(Reference): - status = Enum((u'complete', u'incomplete', u'invalid', u'unknown')) + status = Enum((u'complete', u'incomplete', u'invalid', u'unknown'), default_value=u'complete') def check(self, d): Reference.check(self, d) @@ -187,7 +187,7 @@ Error = ExecuteReplyError class Stream(Reference): - name = Enum((u'stdout', u'stderr')) + name = Enum((u'stdout', u'stderr'), default_value=u'stdout') text = Unicode() diff --git a/IPython/parallel/controller/scheduler.py b/IPython/parallel/controller/scheduler.py index 4f13a1b..55cc37f 100644 --- a/IPython/parallel/controller/scheduler.py +++ b/IPython/parallel/controller/scheduler.py @@ -171,8 +171,8 @@ class TaskScheduler(SessionFactory): """ ) scheme_name = Enum(('leastload', 'pure', 'lru', 'plainrandom', 'weighted', 'twobin'), - 'leastload', config=True, allow_none=False, - help="""select the task scheduler scheme [default: Python LRU] + 'leastload', config=True, +help="""select the task scheduler scheme [default: Python LRU] Options are: 'pure', 'lru', 'plainrandom', 'weighted', 'twobin','leastload'""" ) def _scheme_name_changed(self, old, new): diff --git a/IPython/terminal/console/interactiveshell.py b/IPython/terminal/console/interactiveshell.py index ef97c87..cef8630 100644 --- a/IPython/terminal/console/interactiveshell.py +++ b/IPython/terminal/console/interactiveshell.py @@ -50,7 +50,7 @@ class ZMQTerminalInteractiveShell(TerminalInteractiveShell): ) image_handler = Enum(('PIL', 'stream', 'tempfile', 'callable'), - config=True, help= + config=True, allow_none=True, help= """ Handler for image type output. This is useful, for example, when connecting to the kernel in which pylab inline backend is @@ -99,7 +99,7 @@ class ZMQTerminalInteractiveShell(TerminalInteractiveShell): mime_preference = List( default_value=['image/png', 'image/jpeg', 'image/svg+xml'], - config=True, allow_none=False, help= + config=True, help= """ Preferred object representation MIME type in order. First matched MIME type will be used. diff --git a/IPython/utils/tests/test_traitlets.py b/IPython/utils/tests/test_traitlets.py index 2a3ba48..8344a3d 100644 --- a/IPython/utils/tests/test_traitlets.py +++ b/IPython/utils/tests/test_traitlets.py @@ -976,8 +976,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 LenListTrait(HasTraits): @@ -1431,14 +1431,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): @@ -1454,14 +1454,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 4c26e36..c69aeeb 100644 --- a/IPython/utils/traitlets.py +++ b/IPython/utils/traitlets.py @@ -815,7 +815,7 @@ class Type(ClassBasedTraitType): may be specified in a string like: 'foo.bar.MyClass'. The string is resolved into real class, when the parent :class:`HasTraits` class is instantiated. - allow_none : boolean + allow_none : bool [ default True ] Indicates whether None is allowed as an assignable value. Even if ``False``, the default value may be ``None``. """ @@ -912,7 +912,7 @@ class Instance(ClassBasedTraitType): Positional arguments for generating the default value. kw : dict Keyword arguments for generating the default value. - allow_none : bool + allow_none : bool [default True] Indicates whether None is allowed as a value. Notes @@ -1334,9 +1334,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: @@ -1372,7 +1372,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. @@ -1398,7 +1398,7 @@ class Container(Instance): The default value for the Trait. Must be list/tuple/set, and will be cast to the container type. - allow_none : Bool [ default True ] + allow_none : bool [ default False ] Whether to allow the value to be None **metadata : any @@ -1468,8 +1468,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)``, @@ -1500,7 +1499,7 @@ class List(Container): maxlen : Int [ default sys.maxsize ] The maximum length of the input list - allow_none : Bool [ default True ] + allow_none : bool [ default False ] Whether to allow the value to be None **metadata : any @@ -1510,7 +1509,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." \ @@ -1544,7 +1543,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. @@ -1575,7 +1574,7 @@ class Tuple(Container): will be cast to a tuple. If `traits` are specified, the `default_value` must conform to the shape and type they specify. - allow_none : Bool [ default True ] + allow_none : bool [ default False ] Whether to allow the value to be None **metadata : any @@ -1606,8 +1605,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: @@ -1640,7 +1638,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)``, @@ -1662,7 +1660,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 @@ -1685,7 +1683,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