switch order of ContextManager and Generic (#1382)

Since ContextManager inherits from Generic, too, listing Generic first, in the list of base classes, results in a cyclic MRO.
This commit is contained in:
Matthias Kramm
2017-06-01 18:06:43 -07:00
committed by Guido van Rossum
parent 4656153478
commit a02f9b6d46

View File

@@ -20,7 +20,7 @@ _ExitFunc = Callable[[Optional[Type[BaseException]],
_CM_EF = TypeVar('_CM_EF', ContextManager, _ExitFunc)
if sys.version_info >= (3, 2):
class GeneratorContextManager(Generic[_T], ContextManager[_T]):
class GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: ...
else:
@@ -29,7 +29,7 @@ else:
if sys.version_info < (3,):
def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ...
class closing(Generic[_T], ContextManager[_T]):
class closing(ContextManager[_T], Generic[_T]):
def __init__(self, thing: _T) -> None: ...
if sys.version_info >= (3, 4):