mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-24 18:48:46 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from _typeshed import Self
|
||||
from types import CodeType, FrameType, TracebackType, coroutine
|
||||
from typing import Any, Coroutine, Generator, Generic, Iterator, Optional, Type, TypeVar, Union
|
||||
from typing import Any, Coroutine, Generator, Generic, Iterator, Type, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
@@ -15,9 +15,7 @@ class AsyncBase(Generic[_T]):
|
||||
class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]):
|
||||
def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ...
|
||||
def send(self, value: _T_contra) -> _T_co: ...
|
||||
def throw(
|
||||
self, typ: Type[BaseException], val: Union[BaseException, object] = ..., tb: Optional[TracebackType] = ...
|
||||
) -> _T_co: ...
|
||||
def throw(self, typ: Type[BaseException], val: BaseException | object = ..., tb: TracebackType | None = ...) -> _T_co: ...
|
||||
def close(self) -> None: ...
|
||||
@property
|
||||
def gi_frame(self) -> FrameType: ...
|
||||
@@ -32,5 +30,5 @@ class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]):
|
||||
async def __anext__(self) -> _V_co: ...
|
||||
async def __aenter__(self) -> _V_co: ...
|
||||
async def __aexit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import sys
|
||||
from _typeshed import StrOrBytesPath
|
||||
from os import stat_result
|
||||
from typing import Optional, Sequence, Union, overload
|
||||
from typing import Sequence, Union, overload
|
||||
|
||||
_FdOrAnyPath = Union[int, StrOrBytesPath]
|
||||
|
||||
async def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
|
||||
async def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ...
|
||||
async def rename(
|
||||
src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...
|
||||
src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ...
|
||||
) -> None: ...
|
||||
async def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ...
|
||||
async def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ...
|
||||
async def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
@overload
|
||||
async def sendfile(__out_fd: int, __in_fd: int, offset: Optional[int], count: int) -> int: ...
|
||||
async def sendfile(__out_fd: int, __in_fd: int, offset: int | None, count: int) -> int: ...
|
||||
@overload
|
||||
async def sendfile(
|
||||
__out_fd: int,
|
||||
|
||||
@@ -7,7 +7,7 @@ from _typeshed import (
|
||||
StrOrBytesPath,
|
||||
)
|
||||
from asyncio import AbstractEventLoop
|
||||
from typing import Any, Callable, Optional, Union, overload
|
||||
from typing import Any, Callable, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..base import AiofilesContextManager
|
||||
@@ -23,14 +23,14 @@ def open(
|
||||
file: _OpenFile,
|
||||
mode: OpenTextMode = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
opener: _Opener | None = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
loop: AbstractEventLoop | None = ...,
|
||||
executor: Any | None = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncTextIOWrapper]: ...
|
||||
|
||||
# Unbuffered binary: returns a FileIO
|
||||
@@ -43,26 +43,26 @@ def open(
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
opener: _Opener | None = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
loop: AbstractEventLoop | None = ...,
|
||||
executor: Any | None = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncFileIO]: ...
|
||||
|
||||
# Buffered binary reading/updating: AsyncBufferedReader
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
mode: Union[OpenBinaryModeReading, OpenBinaryModeUpdating],
|
||||
mode: OpenBinaryModeReading | OpenBinaryModeUpdating,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
opener: _Opener | None = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
loop: AbstractEventLoop | None = ...,
|
||||
executor: Any | None = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncBufferedReader]: ...
|
||||
|
||||
# Buffered binary writing: AsyncBufferedIOBase
|
||||
@@ -75,10 +75,10 @@ def open(
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
opener: _Opener | None = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
loop: AbstractEventLoop | None = ...,
|
||||
executor: Any | None = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncBufferedIOBase]: ...
|
||||
|
||||
# Buffering cannot be determined: fall back to _UnknownAsyncBinaryIO
|
||||
@@ -91,8 +91,8 @@ def open(
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
opener: _Opener | None = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
loop: AbstractEventLoop | None = ...,
|
||||
executor: Any | None = ...,
|
||||
) -> AiofilesContextManager[None, None, _UnknownAsyncBinaryIO]: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
|
||||
from io import FileIO
|
||||
from typing import Iterable, List, Optional, Union
|
||||
from typing import Iterable, List
|
||||
|
||||
from ..base import AsyncBase
|
||||
|
||||
@@ -9,13 +9,13 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
|
||||
async def flush(self) -> None: ...
|
||||
async def isatty(self) -> bool: ...
|
||||
async def read(self, __size: int = ...) -> bytes: ...
|
||||
async def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ...
|
||||
async def readline(self, __size: Optional[int] = ...) -> bytes: ...
|
||||
async def readinto(self, __buffer: WriteableBuffer) -> int | None: ...
|
||||
async def readline(self, __size: int | None = ...) -> bytes: ...
|
||||
async def readlines(self, __hint: int = ...) -> List[bytes]: ...
|
||||
async def seek(self, __offset: int, __whence: int = ...) -> int: ...
|
||||
async def seekable(self) -> bool: ...
|
||||
async def tell(self) -> int: ...
|
||||
async def truncate(self, __size: Optional[int] = ...) -> int: ...
|
||||
async def truncate(self, __size: int | None = ...) -> int: ...
|
||||
async def writable(self) -> bool: ...
|
||||
async def write(self, __b: ReadableBuffer) -> int: ...
|
||||
async def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ...
|
||||
@@ -26,7 +26,7 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
@property
|
||||
def name(self) -> Union[StrOrBytesPath, int]: ...
|
||||
def name(self) -> StrOrBytesPath | int: ...
|
||||
|
||||
class AsyncBufferedIOBase(_UnknownAsyncBinaryIO):
|
||||
async def read1(self, __size: int = ...) -> bytes: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from typing import BinaryIO, Iterable, List, Optional, Tuple, Union
|
||||
from typing import BinaryIO, Iterable, List, Tuple
|
||||
|
||||
from ..base import AsyncBase
|
||||
|
||||
@@ -7,13 +7,13 @@ class AsyncTextIOWrapper(AsyncBase[str]):
|
||||
async def close(self) -> None: ...
|
||||
async def flush(self) -> None: ...
|
||||
async def isatty(self) -> bool: ...
|
||||
async def read(self, __size: Optional[int] = ...) -> str: ...
|
||||
async def read(self, __size: int | None = ...) -> str: ...
|
||||
async def readline(self, __size: int = ...) -> str: ...
|
||||
async def readlines(self, __hint: int = ...) -> List[str]: ...
|
||||
async def seek(self, __offset: int, __whence: int = ...) -> int: ...
|
||||
async def seekable(self) -> bool: ...
|
||||
async def tell(self) -> int: ...
|
||||
async def truncate(self, __size: Optional[int] = ...) -> int: ...
|
||||
async def truncate(self, __size: int | None = ...) -> int: ...
|
||||
async def writable(self) -> bool: ...
|
||||
async def write(self, __b: str) -> int: ...
|
||||
async def writelines(self, __lines: Iterable[str]) -> None: ...
|
||||
@@ -27,12 +27,12 @@ class AsyncTextIOWrapper(AsyncBase[str]):
|
||||
@property
|
||||
def encoding(self) -> str: ...
|
||||
@property
|
||||
def errors(self) -> Optional[str]: ...
|
||||
def errors(self) -> str | None: ...
|
||||
@property
|
||||
def line_buffering(self) -> bool: ...
|
||||
@property
|
||||
def newlines(self) -> Union[str, Tuple[str, ...], None]: ...
|
||||
def newlines(self) -> str | Tuple[str, ...] | None: ...
|
||||
@property
|
||||
def name(self) -> Union[StrOrBytesPath, int]: ...
|
||||
def name(self) -> StrOrBytesPath | int: ...
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user