mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
asyncio.locks: fix _ContextManagerMixin base class (#3979)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from typing import Any, Callable, Type, TypeVar, Union, Optional, Awaitable
|
||||
import sys
|
||||
from typing import Any, Callable, Iterable, Generator, Type, TypeVar, Union, Optional, Awaitable
|
||||
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
@@ -6,17 +7,28 @@ from types import TracebackType
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
class _ContextManager:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
class _ContextManagerMixin(Future[_ContextManager]):
|
||||
# Apparently this exists to *prohibit* use as a context manager.
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
class _ContextManagerMixin:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
|
||||
else:
|
||||
class _ContextManager:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
class _ContextManagerMixin:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
# Apparently this exists to *prohibit* use as a context manager.
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def __iter__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||
def __await__(self) -> Generator[Any, None, _ContextManager]: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
|
||||
|
||||
|
||||
class Lock(_ContextManagerMixin):
|
||||
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user