diff --git a/stdlib/3/asyncio/__init__.pyi b/stdlib/3/asyncio/__init__.pyi index 885dfce09..cada742b4 100644 --- a/stdlib/3/asyncio/__init__.pyi +++ b/stdlib/3/asyncio/__init__.pyi @@ -18,8 +18,6 @@ from asyncio.streams import ( StreamReaderProtocol as StreamReaderProtocol, open_connection as open_connection, start_server as start_server, - IncompleteReadError as IncompleteReadError, - LimitOverrunError as LimitOverrunError, ) from asyncio.subprocess import ( create_subprocess_exec as create_subprocess_exec, @@ -35,9 +33,6 @@ from asyncio.transports import ( ) from asyncio.futures import ( Future as Future, - CancelledError as CancelledError, - TimeoutError as TimeoutError, - InvalidStateError as InvalidStateError, wrap_future as wrap_future, ) from asyncio.tasks import ( @@ -122,4 +117,27 @@ DefaultEventLoopPolicy: Type[AbstractEventLoopPolicy] # TODO: AbstractChildWatcher (UNIX only) +if sys.version_info >= (3, 8): + from asyncio.exceptions import ( + CancelledError as CancelledError, + IncompleteReadError as IncompleteReadError, + InvalidStateError as InvalidStateError, + LimitOverrunError as LimitOverrunError, + SendfileNotAvailableError as SendfileNotAvailableError, + TimeoutError as TimeoutError, + ) +else: + from asyncio.events import ( + SendfileNotAvailableError as SendfileNotAvailableError + ) + from asyncio.futures import ( + CancelledError as CancelledError, + TimeoutError as TimeoutError, + InvalidStateError as InvalidStateError, + ) + from asyncio.streams import ( + IncompleteReadError as IncompleteReadError, + LimitOverrunError as LimitOverrunError, + ) + __all__: List[str] diff --git a/stdlib/3/asyncio/events.pyi b/stdlib/3/asyncio/events.pyi index 66f7c9f9e..e766d9b08 100644 --- a/stdlib/3/asyncio/events.pyi +++ b/stdlib/3/asyncio/events.pyi @@ -303,3 +303,6 @@ def _get_running_loop() -> AbstractEventLoop: ... if sys.version_info >= (3, 7): def get_running_loop() -> AbstractEventLoop: ... + +if sys.version_info < (3, 8): + class SendfileNotAvailableError(RuntimeError): ... diff --git a/stdlib/3/asyncio/exceptions.pyi b/stdlib/3/asyncio/exceptions.pyi new file mode 100644 index 000000000..645481a0a --- /dev/null +++ b/stdlib/3/asyncio/exceptions.pyi @@ -0,0 +1,17 @@ +import sys +from typing import List, Optional + +if sys.version_info >= (3, 8): + class CancelledError(BaseException): ... + class TimeoutError(Exception): ... + class InvalidStateError(Exception): ... + class SendfileNotAvailableError(RuntimeError): ... + class IncompleteReadError(EOFError): + expected: Optional[int] + partial: bytes + def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... + class LimitOverrunError(Exception): + consumed: int + def __init__(self, message: str, consumed: int) -> None: ... + + __all__: List[str] diff --git a/stdlib/3/asyncio/futures.pyi b/stdlib/3/asyncio/futures.pyi index 4ebaa339e..5ce41c23d 100644 --- a/stdlib/3/asyncio/futures.pyi +++ b/stdlib/3/asyncio/futures.pyi @@ -2,12 +2,15 @@ import sys from typing import Any, Union, Callable, TypeVar, Type, List, Iterable, Generator, Awaitable, Optional, Tuple from .events import AbstractEventLoop from concurrent.futures import ( - CancelledError as CancelledError, - TimeoutError as TimeoutError, Future as _ConcurrentFuture, Error, ) +if sys.version_info < (3, 8): + from concurrent.futures import CancelledError as CancelledError + from concurrent.futures import TimeoutError as TimeoutError + class InvalidStateError(Error): ... + if sys.version_info >= (3, 7): from contextvars import Context @@ -16,8 +19,6 @@ __all__: List[str] _T = TypeVar('_T') _S = TypeVar('_S') -class InvalidStateError(Error): ... - class _TracebackLogger: exc: BaseException tb: List[str] diff --git a/stdlib/3/asyncio/streams.pyi b/stdlib/3/asyncio/streams.pyi index 68271c0fe..e1ce96404 100644 --- a/stdlib/3/asyncio/streams.pyi +++ b/stdlib/3/asyncio/streams.pyi @@ -11,14 +11,15 @@ _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Await __all__: List[str] -class IncompleteReadError(EOFError): - expected: Optional[int] - partial: bytes - def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... +if sys.version_info < (3, 8): + class IncompleteReadError(EOFError): + expected: Optional[int] + partial: bytes + def __init__(self, partial: bytes, expected: Optional[int]) -> None: ... -class LimitOverrunError(Exception): - consumed: int - def __init__(self, message: str, consumed: int) -> None: ... + class LimitOverrunError(Exception): + consumed: int + def __init__(self, message: str, consumed: int) -> None: ... @coroutines.coroutine def open_connection(