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

Skip to content

Commit 2098e1d

Browse files
committed
move sentinel out of IPython.utils.signature
signature is a backport of a stdlib file, and not an appropriate place for new code. Further, to avoid adding a new trivial module to genutils, a copy is added each place we've used a sentinel
1 parent 2a9139a commit 2098e1d

7 files changed

Lines changed: 54 additions & 18 deletions

File tree

IPython/core/formatters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from IPython.config.configurable import Configurable
2323
from IPython.core.getipython import get_ipython
24-
from IPython.utils.signatures import Sentinel
24+
from IPython.utils.sentinel import Sentinel
2525
from IPython.lib import pretty
2626
from IPython.utils.traitlets import (
2727
Bool, Dict, Integer, Unicode, CUnicode, ObjectName, List,

IPython/utils/sentinel.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Sentinel class for constants with useful reprs"""
2+
3+
# Copyright (c) IPython Development Team.
4+
# Distributed under the terms of the Modified BSD License.
5+
6+
class Sentinel(object):
7+
8+
def __init__(self, name, module, docstring=None):
9+
self.name = name
10+
self.module = module
11+
if docstring:
12+
self.__doc__ = docstring
13+
14+
15+
def __repr__(self):
16+
return str(self.module)+'.'+self.name
17+

IPython/utils/signatures.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -815,18 +815,3 @@ def __str__(self):
815815

816816
return rendered
817817

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-

jupyter_nbformat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from . import v2
1515
from . import v3
1616
from . import v4
17-
from IPython.utils.signatures import Sentinel
17+
from .sentinel import Sentinel
1818

1919
__all__ = ['versions', 'validate', 'ValidationError', 'convert', 'from_dict',
2020
'NotebookNode', 'current_nbformat', 'current_nbformat_minor',

jupyter_nbformat/sentinel.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Sentinel class for constants with useful reprs"""
2+
3+
# Copyright (c) IPython Development Team.
4+
# Distributed under the terms of the Modified BSD License.
5+
6+
class Sentinel(object):
7+
8+
def __init__(self, name, module, docstring=None):
9+
self.name = name
10+
self.module = module
11+
if docstring:
12+
self.__doc__ = docstring
13+
14+
15+
def __repr__(self):
16+
return str(self.module)+'.'+self.name
17+

traitlets/sentinel.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Sentinel class for constants with useful reprs"""
2+
3+
# Copyright (c) IPython Development Team.
4+
# Distributed under the terms of the Modified BSD License.
5+
6+
class Sentinel(object):
7+
8+
def __init__(self, name, module, docstring=None):
9+
self.name = name
10+
self.module = module
11+
if docstring:
12+
self.__doc__ = docstring
13+
14+
15+
def __repr__(self):
16+
return str(self.module)+'.'+self.name
17+

traitlets/traitlets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
from IPython.utils import py3compat
5757
from IPython.utils import eventful
5858
from IPython.utils.getargspec import getargspec
59-
from IPython.utils.signatures import Sentinel
6059
from IPython.utils.importstring import import_item
6160
from IPython.utils.py3compat import iteritems, string_types
6261
from IPython.testing.skipdoctest import skip_doctest
6362

63+
from .sentinel import Sentinel
6464
SequenceTypes = (list, tuple, set, frozenset)
6565

6666
#-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)