summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2016-04-08 19:15:27 (GMT)
committerBrett Cannon <brett@python.org>2016-04-08 19:15:27 (GMT)
commit9e080e0e741dd70cf86500f848eee19cf8b29efa (patch)
tree7d5a4fa6c9279df0c3c3bddd2d041619a6862fa7 /Lib/typing.py
parentc5b5ba9bdafaf2542ac2e6939f025a01a10549c2 (diff)
downloadcpython-9e080e0e741dd70cf86500f848eee19cf8b29efa.zip
cpython-9e080e0e741dd70cf86500f848eee19cf8b29efa.tar.gz
cpython-9e080e0e741dd70cf86500f848eee19cf8b29efa.tar.bz2
Issue #25609: Introduce contextlib.AbstractContextManager and
typing.ContextManager.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 6ead3c4..42a9ea3 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1,6 +1,7 @@
import abc
from abc import abstractmethod, abstractproperty
import collections
+import contextlib
import functools
import re as stdlib_re # Avoid confusion with the re we export.
import sys
@@ -1530,6 +1531,12 @@ class ValuesView(MappingView[VT_co], extra=collections_abc.ValuesView):
pass
+if hasattr(contextlib, 'AbstractContextManager'):
+ class ContextManager(Generic[T_co], extra=contextlib.AbstractContextManager):
+ __slots__ = ()
+ __all__.append('ContextManager')
+
+
class Dict(dict, MutableMapping[KT, VT]):
def __new__(cls, *args, **kwds):