mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Extract asyncio exceptions into a separate module (Python 3.8) (#3356)
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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): ...
|
||||
|
||||
17
stdlib/3/asyncio/exceptions.pyi
Normal file
17
stdlib/3/asyncio/exceptions.pyi
Normal file
@@ -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]
|
||||
@@ -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]
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user