Skip to content

Commit 609b402

Browse files
Merge pull request #29 from vidartf/fix-sentinel
Copy Sentinel implementation from traitlets
2 parents 30f3937 + 8978bc6 commit 609b402

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

traittypes/traittypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import inspect
22
import warnings
33

4-
from traitlets import TraitType, TraitError, Undefined, Sentinel
4+
from traitlets import TraitType, TraitError, Undefined
5+
from .utils import Sentinel
56

67
class _DelayedImportError(object):
78
def __init__(self, package_name):

traittypes/utils.py

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

0 commit comments

Comments
 (0)