mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from socket import socket
|
||||
from typing import Any, Dict, FrozenSet, Iterable, List, Optional, Sequence, Set, Tuple, Union
|
||||
from typing import Any, Dict, FrozenSet, Iterable, List, Sequence, Set, Tuple
|
||||
|
||||
from .compat import HAS_IPV6 as HAS_IPV6, PY2 as PY2, WIN as WIN, string_types as string_types
|
||||
from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS
|
||||
@@ -7,13 +7,13 @@ from .proxy_headers import PROXY_HEADERS as PROXY_HEADERS
|
||||
truthy: FrozenSet[Any]
|
||||
KNOWN_PROXY_HEADERS: FrozenSet[Any]
|
||||
|
||||
def asbool(s: Optional[Union[bool, str, int]]) -> bool: ...
|
||||
def asbool(s: bool | str | int | None) -> bool: ...
|
||||
def asoctal(s: str) -> int: ...
|
||||
def aslist_cronly(value: str) -> List[str]: ...
|
||||
def aslist(value: str) -> List[str]: ...
|
||||
def asset(value: Optional[str]) -> Set[str]: ...
|
||||
def slash_fixed_str(s: Optional[str]) -> str: ...
|
||||
def str_iftruthy(s: Optional[str]) -> Optional[str]: ...
|
||||
def asset(value: str | None) -> Set[str]: ...
|
||||
def slash_fixed_str(s: str | None) -> str: ...
|
||||
def str_iftruthy(s: str | None) -> str | None: ...
|
||||
def as_socket_list(sockets: Sequence[object]) -> List[socket]: ...
|
||||
|
||||
class _str_marker(str): ...
|
||||
@@ -25,11 +25,11 @@ class Adjustments:
|
||||
port: _int_marker = ...
|
||||
listen: List[str] = ...
|
||||
threads: int = ...
|
||||
trusted_proxy: Optional[str] = ...
|
||||
trusted_proxy_count: Optional[int] = ...
|
||||
trusted_proxy: str | None = ...
|
||||
trusted_proxy_count: int | None = ...
|
||||
trusted_proxy_headers: Set[str] = ...
|
||||
log_untrusted_proxy_headers: bool = ...
|
||||
clear_untrusted_proxy_headers: Union[_bool_marker, bool] = ...
|
||||
clear_untrusted_proxy_headers: _bool_marker | bool = ...
|
||||
url_scheme: str = ...
|
||||
url_prefix: str = ...
|
||||
ident: str = ...
|
||||
@@ -46,7 +46,7 @@ class Adjustments:
|
||||
max_request_header_size: int = ...
|
||||
max_request_body_size: int = ...
|
||||
expose_tracebacks: bool = ...
|
||||
unix_socket: Optional[str] = ...
|
||||
unix_socket: str | None = ...
|
||||
unix_socket_perms: int = ...
|
||||
socket_options: List[Tuple[int, int, int]] = ...
|
||||
asyncore_loop_timeout: int = ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from io import BufferedIOBase, BufferedRandom, BytesIO
|
||||
from typing import Any, Callable, Optional
|
||||
from typing import Any, Callable
|
||||
|
||||
COPY_BYTES: int
|
||||
STRBUF_LIMIT: int
|
||||
@@ -7,7 +7,7 @@ STRBUF_LIMIT: int
|
||||
class FileBasedBuffer:
|
||||
remain: int = ...
|
||||
file: BytesIO = ...
|
||||
def __init__(self, file: BytesIO, from_buffer: Optional[BytesIO] = ...) -> None: ...
|
||||
def __init__(self, file: BytesIO, from_buffer: BytesIO | None = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
__bool__: Callable[[], bool] = ...
|
||||
@@ -20,12 +20,12 @@ class FileBasedBuffer:
|
||||
def close(self) -> None: ...
|
||||
|
||||
class TempfileBasedBuffer(FileBasedBuffer):
|
||||
def __init__(self, from_buffer: Optional[BytesIO] = ...) -> None: ...
|
||||
def __init__(self, from_buffer: BytesIO | None = ...) -> None: ...
|
||||
def newfile(self) -> BufferedRandom: ...
|
||||
|
||||
class BytesIOBasedBuffer(FileBasedBuffer):
|
||||
file: BytesIO = ...
|
||||
def __init__(self, from_buffer: Optional[BytesIO] = ...) -> None: ...
|
||||
def __init__(self, from_buffer: BytesIO | None = ...) -> None: ...
|
||||
def newfile(self) -> BytesIO: ...
|
||||
|
||||
class ReadOnlyFileBasedBuffer(FileBasedBuffer):
|
||||
@@ -33,16 +33,16 @@ class ReadOnlyFileBasedBuffer(FileBasedBuffer):
|
||||
block_size: int = ...
|
||||
def __init__(self, file: BytesIO, block_size: int = ...) -> None: ...
|
||||
remain: int = ...
|
||||
def prepare(self, size: Optional[int] = ...) -> int: ...
|
||||
def prepare(self, size: int | None = ...) -> int: ...
|
||||
def get(self, numbytes: int = ..., skip: bool = ...) -> bytes: ...
|
||||
def __iter__(self) -> ReadOnlyFileBasedBuffer: ...
|
||||
def next(self) -> Optional[bytes]: ...
|
||||
__next__: Callable[[], Optional[bytes]] = ...
|
||||
def next(self) -> bytes | None: ...
|
||||
__next__: Callable[[], bytes | None] = ...
|
||||
def append(self, s: Any) -> None: ...
|
||||
|
||||
class OverflowableBuffer:
|
||||
overflowed: bool = ...
|
||||
buf: Optional[BufferedIOBase] = ...
|
||||
buf: BufferedIOBase | None = ...
|
||||
strbuf: bytes = ...
|
||||
overflow: int = ...
|
||||
def __init__(self, overflow: int) -> None: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from socket import socket
|
||||
from threading import Condition, Lock
|
||||
from typing import Mapping, Optional, Sequence, Tuple
|
||||
from typing import Mapping, Sequence, Tuple
|
||||
|
||||
from waitress.adjustments import Adjustments
|
||||
from waitress.buffers import OverflowableBuffer
|
||||
@@ -33,7 +33,7 @@ class HTTPChannel(wasyncore.dispatcher):
|
||||
outbuf_lock: Condition = ...
|
||||
addr: Tuple[str, int] = ...
|
||||
def __init__(
|
||||
self, server: BaseWSGIServer, sock: socket, addr: str, adj: Adjustments, map: Optional[Mapping[int, socket]] = ...
|
||||
self, server: BaseWSGIServer, sock: socket, addr: str, adj: Adjustments, map: Mapping[int, socket] | None = ...
|
||||
) -> None: ...
|
||||
def writable(self) -> bool: ...
|
||||
def handle_write(self) -> None: ...
|
||||
@@ -42,8 +42,8 @@ class HTTPChannel(wasyncore.dispatcher):
|
||||
def received(self, data: bytes) -> bool: ...
|
||||
connected: bool = ...
|
||||
def handle_close(self) -> None: ...
|
||||
def add_channel(self, map: Optional[Mapping[int, socket]] = ...) -> None: ...
|
||||
def del_channel(self, map: Optional[Mapping[int, socket]] = ...) -> None: ...
|
||||
def add_channel(self, map: Mapping[int, socket] | None = ...) -> None: ...
|
||||
def del_channel(self, map: Mapping[int, socket] | None = ...) -> None: ...
|
||||
def write_soon(self, data: bytes) -> int: ...
|
||||
def service(self) -> None: ...
|
||||
def cancel(self) -> None: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from io import TextIOWrapper
|
||||
from typing import Any, Optional, Tuple
|
||||
from typing import Any, Tuple
|
||||
|
||||
PY2: bool
|
||||
PY3: bool
|
||||
@@ -18,7 +18,7 @@ def tobytes(s: str) -> bytes: ...
|
||||
|
||||
exec_: Any
|
||||
|
||||
def reraise(tp: Any, value: BaseException, tb: Optional[str] = ...) -> None: ...
|
||||
def reraise(tp: Any, value: BaseException, tb: str | None = ...) -> None: ...
|
||||
|
||||
MAXINT: int
|
||||
HAS_IPV6: bool
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from io import BytesIO
|
||||
from typing import Any, Mapping, Optional, Pattern, Sequence, Tuple, Union
|
||||
from typing import Any, Mapping, Pattern, Sequence, Tuple
|
||||
|
||||
from waitress.adjustments import Adjustments
|
||||
from waitress.receiver import ChunkedReceiver, FixedStreamReceiver
|
||||
@@ -20,9 +20,9 @@ class HTTPRequestParser:
|
||||
content_length: int = ...
|
||||
header_bytes_received: int = ...
|
||||
body_bytes_received: int = ...
|
||||
body_rcv: Optional[Union[ChunkedReceiver, FixedStreamReceiver]] = ...
|
||||
body_rcv: ChunkedReceiver | FixedStreamReceiver | None = ...
|
||||
version: str = ...
|
||||
error: Optional[Error] = ...
|
||||
error: Error | None = ...
|
||||
connection_close: bool = ...
|
||||
headers: Mapping[str, str] = ...
|
||||
adj: Adjustments = ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from logging import Logger
|
||||
from typing import Any, Callable, Mapping, NamedTuple, Optional, Sequence, Set
|
||||
from typing import Any, Callable, Mapping, NamedTuple, Sequence, Set
|
||||
|
||||
from .utilities import BadRequest as BadRequest
|
||||
|
||||
@@ -19,9 +19,9 @@ class MalformedProxyHeader(Exception):
|
||||
|
||||
def proxy_headers_middleware(
|
||||
app: Any,
|
||||
trusted_proxy: Optional[str] = ...,
|
||||
trusted_proxy: str | None = ...,
|
||||
trusted_proxy_count: int = ...,
|
||||
trusted_proxy_headers: Optional[Set[str]] = ...,
|
||||
trusted_proxy_headers: Set[str] | None = ...,
|
||||
clear_untrusted: bool = ...,
|
||||
log_untrusted: bool = ...,
|
||||
logger: Logger = ...,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
from io import BytesIO
|
||||
from typing import Optional
|
||||
|
||||
from waitress.buffers import OverflowableBuffer
|
||||
from waitress.utilities import BadRequest
|
||||
@@ -23,7 +22,7 @@ class ChunkedReceiver:
|
||||
all_chunks_received: bool = ...
|
||||
trailer: bytes = ...
|
||||
completed: bool = ...
|
||||
error: Optional[BadRequest] = ...
|
||||
error: BadRequest | None = ...
|
||||
buf: OverflowableBuffer = ...
|
||||
def __init__(self, buf: OverflowableBuffer) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from io import TextIOWrapper
|
||||
from typing import Any, Callable, Optional, Pattern, Sequence, Tuple
|
||||
from typing import Any, Callable, Pattern, Sequence, Tuple
|
||||
|
||||
HELP: str
|
||||
RUNNER_PATTERN: Pattern[Any]
|
||||
|
||||
def match(obj_name: str) -> Tuple[str, str]: ...
|
||||
def resolve(module_name: str, object_name: str) -> Any: ...
|
||||
def show_help(stream: TextIOWrapper, name: str, error: Optional[str] = ...) -> None: ...
|
||||
def show_help(stream: TextIOWrapper, name: str, error: str | None = ...) -> None: ...
|
||||
def show_exception(stream: TextIOWrapper) -> None: ...
|
||||
def run(argv: Sequence[str] = ..., _serve: Callable[..., Any] = ...) -> None: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from socket import socket
|
||||
from typing import Any, Optional, Sequence, Tuple, Union
|
||||
from typing import Any, Sequence, Tuple
|
||||
|
||||
from waitress.adjustments import Adjustments
|
||||
from waitress.channel import HTTPChannel
|
||||
@@ -9,12 +9,12 @@ from . import wasyncore
|
||||
|
||||
def create_server(
|
||||
application: Any,
|
||||
map: Optional[Any] = ...,
|
||||
map: Any | None = ...,
|
||||
_start: bool = ...,
|
||||
_sock: Optional[socket] = ...,
|
||||
_dispatcher: Optional[ThreadedTaskDispatcher] = ...,
|
||||
_sock: socket | None = ...,
|
||||
_dispatcher: ThreadedTaskDispatcher | None = ...,
|
||||
**kw: Any,
|
||||
) -> Union[MultiSocketServer, BaseWSGIServer]: ...
|
||||
) -> MultiSocketServer | BaseWSGIServer: ...
|
||||
|
||||
class MultiSocketServer:
|
||||
asyncore: Any = ...
|
||||
@@ -24,10 +24,10 @@ class MultiSocketServer:
|
||||
task_dispatcher: ThreadedTaskDispatcher = ...
|
||||
def __init__(
|
||||
self,
|
||||
map: Optional[Any] = ...,
|
||||
adj: Optional[Adjustments] = ...,
|
||||
effective_listen: Optional[Sequence[Tuple[str, int]]] = ...,
|
||||
dispatcher: Optional[ThreadedTaskDispatcher] = ...,
|
||||
map: Any | None = ...,
|
||||
adj: Adjustments | None = ...,
|
||||
effective_listen: Sequence[Tuple[str, int]] | None = ...,
|
||||
dispatcher: ThreadedTaskDispatcher | None = ...,
|
||||
) -> None: ...
|
||||
def print_listen(self, format_str: str) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
@@ -50,12 +50,12 @@ class BaseWSGIServer(wasyncore.dispatcher):
|
||||
def __init__(
|
||||
self,
|
||||
application: Any,
|
||||
map: Optional[Any] = ...,
|
||||
map: Any | None = ...,
|
||||
_start: bool = ...,
|
||||
_sock: Optional[Any] = ...,
|
||||
dispatcher: Optional[ThreadedTaskDispatcher] = ...,
|
||||
adj: Optional[Adjustments] = ...,
|
||||
sockinfo: Optional[Any] = ...,
|
||||
_sock: Any | None = ...,
|
||||
dispatcher: ThreadedTaskDispatcher | None = ...,
|
||||
adj: Adjustments | None = ...,
|
||||
sockinfo: Any | None = ...,
|
||||
bind_socket: bool = ...,
|
||||
**kw: Any,
|
||||
) -> None: ...
|
||||
@@ -87,12 +87,12 @@ class UnixWSGIServer(BaseWSGIServer):
|
||||
def __init__(
|
||||
self,
|
||||
application: Any,
|
||||
map: Optional[Any] = ...,
|
||||
map: Any | None = ...,
|
||||
_start: bool = ...,
|
||||
_sock: Optional[Any] = ...,
|
||||
dispatcher: Optional[Any] = ...,
|
||||
adj: Optional[Adjustments] = ...,
|
||||
sockinfo: Optional[Any] = ...,
|
||||
_sock: Any | None = ...,
|
||||
dispatcher: Any | None = ...,
|
||||
adj: Adjustments | None = ...,
|
||||
sockinfo: Any | None = ...,
|
||||
**kw: Any,
|
||||
) -> None: ...
|
||||
def bind_server_socket(self) -> None: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from logging import Logger
|
||||
from threading import Condition, Lock
|
||||
from typing import Any, Deque, Mapping, Optional, Sequence, Tuple
|
||||
from typing import Any, Deque, Mapping, Sequence, Tuple
|
||||
|
||||
from .channel import HTTPChannel
|
||||
from .utilities import Error
|
||||
@@ -30,7 +30,7 @@ class Task:
|
||||
status: str = ...
|
||||
wrote_header: bool = ...
|
||||
start_time: int = ...
|
||||
content_length: Optional[int] = ...
|
||||
content_length: int | None = ...
|
||||
content_bytes_written: int = ...
|
||||
logged_write_excess: bool = ...
|
||||
logged_write_no_body: bool = ...
|
||||
@@ -59,7 +59,7 @@ class ErrorTask(Task):
|
||||
def execute(self) -> None: ...
|
||||
|
||||
class WSGITask(Task):
|
||||
environ: Optional[Any] = ...
|
||||
environ: Any | None = ...
|
||||
response_headers: Sequence[Tuple[str, str]] = ...
|
||||
complete: bool = ...
|
||||
status: str = ...
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import sys
|
||||
from socket import socket
|
||||
from threading import Lock
|
||||
from typing import Callable, Mapping, Optional
|
||||
from typing import Callable, Mapping
|
||||
from typing_extensions import Literal
|
||||
|
||||
from . import wasyncore as wasyncore
|
||||
|
||||
class _triggerbase:
|
||||
kind: Optional[str] = ...
|
||||
kind: str | None = ...
|
||||
lock: Lock = ...
|
||||
thunks: Callable[[None], None] = ...
|
||||
def __init__(self) -> None: ...
|
||||
@@ -16,7 +16,7 @@ class _triggerbase:
|
||||
def handle_connect(self) -> None: ...
|
||||
def handle_close(self) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def pull_trigger(self, thunk: Optional[Callable[[None], None]] = ...) -> None: ...
|
||||
def pull_trigger(self, thunk: Callable[[None], None] | None = ...) -> None: ...
|
||||
def handle_read(self) -> None: ...
|
||||
|
||||
if sys.platform == "linux" or sys.platform == "darwin":
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from io import BytesIO
|
||||
from logging import Logger
|
||||
from socket import socket
|
||||
from typing import Any, Callable, Mapping, Optional, Tuple
|
||||
from typing import Any, Callable, Mapping, Tuple
|
||||
|
||||
from . import compat as compat, utilities as utilities
|
||||
|
||||
@@ -15,14 +15,12 @@ class ExitNow(Exception): ...
|
||||
def read(obj: dispatcher) -> None: ...
|
||||
def write(obj: dispatcher) -> None: ...
|
||||
def readwrite(obj: dispatcher, flags: int) -> None: ...
|
||||
def poll(timeout: float = ..., map: Optional[Mapping[int, socket]] = ...) -> None: ...
|
||||
def poll2(timeout: float = ..., map: Optional[Mapping[int, socket]] = ...) -> None: ...
|
||||
def poll(timeout: float = ..., map: Mapping[int, socket] | None = ...) -> None: ...
|
||||
def poll2(timeout: float = ..., map: Mapping[int, socket] | None = ...) -> None: ...
|
||||
|
||||
poll3 = poll2
|
||||
|
||||
def loop(
|
||||
timeout: float = ..., use_poll: bool = ..., map: Optional[Mapping[int, socket]] = ..., count: Optional[int] = ...
|
||||
) -> None: ...
|
||||
def loop(timeout: float = ..., use_poll: bool = ..., map: Mapping[int, socket] | None = ..., count: int | None = ...) -> None: ...
|
||||
def compact_traceback() -> Tuple[Tuple[str, str, str], BaseException, BaseException, str]: ...
|
||||
|
||||
class dispatcher:
|
||||
@@ -31,24 +29,24 @@ class dispatcher:
|
||||
accepting: bool = ...
|
||||
connecting: bool = ...
|
||||
closing: bool = ...
|
||||
addr: Optional[Tuple[str, int]] = ...
|
||||
addr: Tuple[str, int] | None = ...
|
||||
ignore_log_types: frozenset[Any]
|
||||
logger: Logger = ...
|
||||
compact_traceback: Callable[[], Tuple[Tuple[str, str, str], BaseException, BaseException, str]] = ...
|
||||
socket: Optional[_socket] = ...
|
||||
def __init__(self, sock: Optional[_socket] = ..., map: Optional[Mapping[int, _socket]] = ...) -> None: ...
|
||||
def add_channel(self, map: Optional[Mapping[int, _socket]] = ...) -> None: ...
|
||||
def del_channel(self, map: Optional[Mapping[int, _socket]] = ...) -> None: ...
|
||||
socket: _socket | None = ...
|
||||
def __init__(self, sock: _socket | None = ..., map: Mapping[int, _socket] | None = ...) -> None: ...
|
||||
def add_channel(self, map: Mapping[int, _socket] | None = ...) -> None: ...
|
||||
def del_channel(self, map: Mapping[int, _socket] | None = ...) -> None: ...
|
||||
family_and_type: Tuple[int, int] = ...
|
||||
def create_socket(self, family: int = ..., type: int = ...) -> None: ...
|
||||
def set_socket(self, sock: _socket, map: Optional[Mapping[int, _socket]] = ...) -> None: ...
|
||||
def set_socket(self, sock: _socket, map: Mapping[int, _socket] | None = ...) -> None: ...
|
||||
def set_reuse_addr(self) -> None: ...
|
||||
def readable(self) -> bool: ...
|
||||
def writable(self) -> bool: ...
|
||||
def listen(self, num: int) -> None: ...
|
||||
def bind(self, addr: Tuple[str, int]) -> None: ...
|
||||
def connect(self, address: Tuple[str, int]) -> None: ...
|
||||
def accept(self) -> Optional[Tuple[_socket, Tuple[str, int]]]: ...
|
||||
def accept(self) -> Tuple[_socket, Tuple[str, int]] | None: ...
|
||||
def send(self, data: bytes) -> int: ...
|
||||
def recv(self, buffer_size: int) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
@@ -69,13 +67,13 @@ class dispatcher:
|
||||
|
||||
class dispatcher_with_send(dispatcher):
|
||||
out_buffer: bytes = ...
|
||||
def __init__(self, sock: Optional[socket] = ..., map: Optional[Mapping[int, socket]] = ...) -> None: ...
|
||||
def __init__(self, sock: socket | None = ..., map: Mapping[int, socket] | None = ...) -> None: ...
|
||||
def initiate_send(self) -> None: ...
|
||||
handle_write: Callable[[], None] = ...
|
||||
def writable(self) -> bool: ...
|
||||
def send(self, data: bytes) -> None: ... # type: ignore
|
||||
|
||||
def close_all(map: Optional[Mapping[int, socket]] = ..., ignore_all: bool = ...) -> None: ...
|
||||
def close_all(map: Mapping[int, socket] | None = ..., ignore_all: bool = ...) -> None: ...
|
||||
|
||||
class file_wrapper:
|
||||
fd: BytesIO = ...
|
||||
@@ -83,7 +81,7 @@ class file_wrapper:
|
||||
def __del__(self) -> None: ...
|
||||
def recv(self, *args: Any) -> bytes: ...
|
||||
def send(self, *args: Any) -> bytes: ...
|
||||
def getsockopt(self, level: int, optname: int, buflen: Optional[bool] = ...) -> int: ...
|
||||
def getsockopt(self, level: int, optname: int, buflen: bool | None = ...) -> int: ...
|
||||
read: Callable[..., bytes] = ...
|
||||
write: Callable[..., bytes] = ...
|
||||
def close(self) -> None: ...
|
||||
@@ -91,6 +89,6 @@ class file_wrapper:
|
||||
|
||||
class file_dispatcher(dispatcher):
|
||||
connected: bool = ...
|
||||
def __init__(self, fd: BytesIO, map: Optional[Mapping[int, _socket]] = ...) -> None: ...
|
||||
def __init__(self, fd: BytesIO, map: Mapping[int, _socket] | None = ...) -> None: ...
|
||||
socket: _socket = ...
|
||||
def set_file(self, fd: BytesIO) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user