##// END OF EJS Templates
make sentinel class for some kwargs....
Matthias Bussonnier -
Show More
@@ -21,6 +21,7 b' from decorator import decorator'
21 21
22 22 from IPython.config.configurable import Configurable
23 23 from IPython.core.getipython import get_ipython
24 from IPython.utils.signatures import Sentinel
24 25 from IPython.lib import pretty
25 26 from IPython.utils.traitlets import (
26 27 Bool, Dict, Integer, Unicode, CUnicode, ObjectName, List,
@@ -270,7 +271,13 b' def _get_type(obj):'
270 271 """Return the type of an instance (old and new-style)"""
271 272 return getattr(obj, '__class__', None) or type(obj)
272 273
273 _raise_key_error = object()
274
275 _raise_key_error = Sentinel('_raise_key_error', __name__,
276 """
277 Special value to raise a KeyError
278
279 Raise KeyError in `BaseFormatter.pop` if passed as the default value to `pop`
280 """)
274 281
275 282
276 283 class BaseFormatter(Configurable):
@@ -814,3 +814,19 b' class Signature(object):'
814 814 rendered += ' -> {0}'.format(anno)
815 815
816 816 return rendered
817
818 ## Fake unique value as KWargs, in some places.
819 # do not put docstrings here or they will appear
820 # on created fake values.
821 class Sentinel(object):
822
823 def __init__(self, name, module, docstring=None):
824 self.name = name
825 self.module = module
826 if docstring:
827 self.__doc__ = docstring
828
829
830 def __repr__(self):
831 return str(self.module)+'.'+self.name
832
@@ -14,6 +14,7 b' from . import v1'
14 14 from . import v2
15 15 from . import v3
16 16 from . import v4
17 from IPython.utils.signatures import Sentinel
17 18
18 19 __all__ = ['versions', 'validate', 'ValidationError', 'convert', 'from_dict',
19 20 'NotebookNode', 'current_nbformat', 'current_nbformat_minor',
@@ -40,18 +41,6 b' class NBFormatError(ValueError):'
40 41 pass
41 42
42 43 # no-conversion singleton
43 class Sentinel(object):
44
45 def __init__(self, name, module, docstring=None):
46 self.name = name
47 self.module = module
48 if docstring:
49 self.__doc__ = docstring
50
51
52 def __repr__(self):
53 return str(self.module)+'.'+self.name
54
55 44 NO_CONVERT = Sentinel('NO_CONVERT', __name__,
56 45 """Value to prevent nbformat to convert notebooks to most recent version.
57 46 """)
@@ -56,6 +56,7 b' from warnings import warn'
56 56 from IPython.utils import py3compat
57 57 from IPython.utils import eventful
58 58 from IPython.utils.getargspec import getargspec
59 from IPython.utils.signatures import Sentinel
59 60 from IPython.utils.importstring import import_item
60 61 from IPython.utils.py3compat import iteritems, string_types
61 62 from IPython.testing.skipdoctest import skip_doctest
@@ -67,8 +68,11 b' SequenceTypes = (list, tuple, set, frozenset)'
67 68 #-----------------------------------------------------------------------------
68 69
69 70
70 class NoDefaultSpecified ( object ): pass
71 NoDefaultSpecified = NoDefaultSpecified()
71 NoDefaultSpecified = Sentinel('NoDefaultSpecified', __name__,
72 '''
73 Used in Traitlets to specify that no defaults are set in kwargs
74 '''
75 )
72 76
73 77
74 78 class Undefined ( object ): pass
General Comments 0
You need to be logged in to leave comments. Login now