summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2016-04-15 17:51:30 (GMT)
committerBrett Cannon <brett@python.org>2016-04-15 17:51:30 (GMT)
commitf3ad042bfb1ea4de7358d1c7cd8b5a2eb9e21d01 (patch)
tree16d04d4a627fb1e6bbd19d3b18285f1b8131265f /Lib/typing.py
parent3c149a6832a728281dc87bc6e111117af51059e0 (diff)
downloadcpython-f3ad042bfb1ea4de7358d1c7cd8b5a2eb9e21d01.zip
cpython-f3ad042bfb1ea4de7358d1c7cd8b5a2eb9e21d01.tar.gz
cpython-f3ad042bfb1ea4de7358d1c7cd8b5a2eb9e21d01.tar.bz2
Issue #25609: Backport typing.ContextManager.
This has no semantic impact as the class is guarded with a hasattr() check; this is being done to keep typing.py in sync between Python 3.5 and 3.6 as requested by Guido.
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):