Fixes to ContextManager (#1249)

* add typing.ContextManager for 3.6+ only

This fixes the easier part of #655.

Would it make sense to add a generic typing.ContextManager that exists in any Python version?

* update comment

* fix argument types for ContextManager.__exit__

* add AsyncContextManager

* add @asynccontextmanager

* typing.ContextManager now always exists

* back out async-related changes

Will submit those in a separate PR later

* fix import order

* AbstractContextManager only exists in 3.6+

* AbstractContextManager -> ContextManager
This commit is contained in:
Jelle Zijlstra
2017-05-08 16:21:51 -07:00
committed by Matthias Kramm
parent 385b9c8b66
commit 7dd2f80194
5 changed files with 28 additions and 20 deletions

View File

@@ -3,12 +3,11 @@
from typing import (
Any, Callable, Dict, Iterable, Iterator, List, Optional, Pattern, Sequence,
Set, FrozenSet, TextIO, Tuple, Type, TypeVar, Union, Generic,
overload,
overload, ContextManager
)
import logging
import sys
from types import ModuleType, TracebackType
from contextlib import ContextManager
_T = TypeVar('_T')