Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions stdlib/3/asyncio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 (
Expand Down Expand Up @@ -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]
3 changes: 3 additions & 0 deletions stdlib/3/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 17 additions & 0 deletions stdlib/3/asyncio/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -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]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__all__ should should not be typed (event if existing stubs do this). If __all__ exists, it has the same meaning as in implementation files. In this case it's not necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for correcting.

9 changes: 5 additions & 4 deletions stdlib/3/asyncio/futures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -16,8 +19,6 @@ __all__: List[str]
_T = TypeVar('_T')
_S = TypeVar('_S')

class InvalidStateError(Error): ...

class _TracebackLogger:
exc: BaseException
tb: List[str]
Expand Down
15 changes: 8 additions & 7 deletions stdlib/3/asyncio/streams.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down