diff options
author | Raymond Hettinger <python@rcn.com> | 2017-01-17 06:42:37 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2017-01-17 06:42:37 (GMT) |
commit | 80490525e0e9c08860b0de0c416dbe71c6593af7 (patch) | |
tree | aabf82fd00fdbfe92a1d416223c5d9849b61c5df /Lib/typing.py | |
parent | a105dd3dc0b054f0d7977e19b682a0016b67790f (diff) | |
download | cpython-80490525e0e9c08860b0de0c416dbe71c6593af7.zip cpython-80490525e0e9c08860b0de0c416dbe71c6593af7.tar.gz cpython-80490525e0e9c08860b0de0c416dbe71c6593af7.tar.bz2 |
Issue #29011: Fix an important omission by adding Deque to the typing module.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r-- | Lib/typing.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 34845b7..2821c3c 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -59,6 +59,7 @@ __all__ = [ 'SupportsRound', # Concrete collection types. + 'Deque', 'Dict', 'DefaultDict', 'List', @@ -1771,6 +1772,15 @@ class List(list, MutableSequence[T], extra=list): "use list() instead") return _generic_new(list, cls, *args, **kwds) +class Deque(collections.deque, MutableSequence[T], extra=collections.deque): + + __slots__ = () + + def __new__(cls, *args, **kwds): + if _geqv(cls, Deque): + raise TypeError("Type Deque cannot be instantiated; " + "use deque() instead") + return _generic_new(collections.deque, cls, *args, **kwds) class Set(set, MutableSet[T], extra=set): |