mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import sys
|
||||
from _typeshed import StrPath
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple, Union
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple
|
||||
|
||||
from . import events, protocols, transports
|
||||
from .base_events import Server
|
||||
@@ -9,30 +9,30 @@ _ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Await
|
||||
|
||||
if sys.version_info < (3, 8):
|
||||
class IncompleteReadError(EOFError):
|
||||
expected: Optional[int]
|
||||
expected: int | None
|
||||
partial: bytes
|
||||
def __init__(self, partial: bytes, expected: Optional[int]) -> None: ...
|
||||
def __init__(self, partial: bytes, expected: int | None) -> None: ...
|
||||
class LimitOverrunError(Exception):
|
||||
consumed: int
|
||||
def __init__(self, message: str, consumed: int) -> None: ...
|
||||
|
||||
async def open_connection(
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
host: str | None = ...,
|
||||
port: int | str | None = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
loop: events.AbstractEventLoop | None = ...,
|
||||
limit: int = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
ssl_handshake_timeout: float | None = ...,
|
||||
**kwds: Any,
|
||||
) -> Tuple[StreamReader, StreamWriter]: ...
|
||||
async def start_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
host: str | None = ...,
|
||||
port: int | str | None = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
loop: events.AbstractEventLoop | None = ...,
|
||||
limit: int = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
ssl_handshake_timeout: float | None = ...,
|
||||
**kwds: Any,
|
||||
) -> Server: ...
|
||||
|
||||
@@ -42,29 +42,29 @@ if sys.platform != "win32":
|
||||
else:
|
||||
_PathType = str
|
||||
async def open_unix_connection(
|
||||
path: Optional[_PathType] = ..., *, loop: Optional[events.AbstractEventLoop] = ..., limit: int = ..., **kwds: Any
|
||||
path: _PathType | None = ..., *, loop: events.AbstractEventLoop | None = ..., limit: int = ..., **kwds: Any
|
||||
) -> Tuple[StreamReader, StreamWriter]: ...
|
||||
async def start_unix_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
path: Optional[_PathType] = ...,
|
||||
path: _PathType | None = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
loop: events.AbstractEventLoop | None = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any,
|
||||
) -> Server: ...
|
||||
|
||||
class FlowControlMixin(protocols.Protocol):
|
||||
def __init__(self, loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
|
||||
def __init__(self, loop: events.AbstractEventLoop | None = ...) -> None: ...
|
||||
|
||||
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||
def __init__(
|
||||
self,
|
||||
stream_reader: StreamReader,
|
||||
client_connected_cb: Optional[_ClientConnectedCallback] = ...,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
client_connected_cb: _ClientConnectedCallback | None = ...,
|
||||
loop: events.AbstractEventLoop | None = ...,
|
||||
) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Optional[Exception]) -> None: ...
|
||||
def connection_lost(self, exc: Exception | None) -> None: ...
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> bool: ...
|
||||
|
||||
@@ -73,7 +73,7 @@ class StreamWriter:
|
||||
self,
|
||||
transport: transports.BaseTransport,
|
||||
protocol: protocols.BaseProtocol,
|
||||
reader: Optional[StreamReader],
|
||||
reader: StreamReader | None,
|
||||
loop: events.AbstractEventLoop,
|
||||
) -> None: ...
|
||||
@property
|
||||
@@ -90,7 +90,7 @@ class StreamWriter:
|
||||
async def drain(self) -> None: ...
|
||||
|
||||
class StreamReader:
|
||||
def __init__(self, limit: int = ..., loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
|
||||
def __init__(self, limit: int = ..., loop: events.AbstractEventLoop | None = ...) -> None: ...
|
||||
def exception(self) -> Exception: ...
|
||||
def set_exception(self, exc: Exception) -> None: ...
|
||||
def set_transport(self, transport: transports.BaseTransport) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user