diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 9682568f3f9c..19ec5b1f4bf1 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -25,7 +25,6 @@ "stdlib/tkinter/scrolledtext.pyi", "stdlib/tkinter/tix.pyi", "stdlib/tkinter/ttk.pyi", - "stubs/aiofiles", "stubs/antlr4-python3-runtime", "stubs/auth0-python", "stubs/Authlib", diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index 1de0bbbfdcb1..4b10dfb80613 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,4 +1,6 @@ +from asyncio.events import AbstractEventLoop from collections.abc import Awaitable, Callable, Generator +from concurrent.futures import Executor from contextlib import AbstractAsyncContextManager from types import TracebackType from typing import Any, BinaryIO, Generic, TextIO, TypeVar @@ -8,12 +10,14 @@ _T = TypeVar("_T") _V_co = TypeVar("_V_co", covariant=True) class AsyncBase(Generic[_T]): - def __init__(self, file: TextIO | BinaryIO | None, loop: Any, executor: Any) -> None: ... + def __init__(self, file: TextIO | BinaryIO | None, loop: AbstractEventLoop | None, executor: Executor | None) -> None: ... def __aiter__(self) -> Self: ... async def __anext__(self) -> _T: ... class AsyncIndirectBase(AsyncBase[_T]): - def __init__(self, name: str, loop: Any, executor: Any, indirect: Callable[[], TextIO | BinaryIO]) -> None: ... + def __init__( + self, name: str, loop: AbstractEventLoop | None, executor: Executor | None, indirect: Callable[[], TextIO | BinaryIO] + ) -> None: ... class AiofilesContextManager(Awaitable[_V_co], AbstractAsyncContextManager[_V_co]): def __init__(self, coro: Awaitable[_V_co]) -> None: ... diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 5a3de3b591f0..34564f3488e2 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -2,8 +2,9 @@ import sys from _typeshed import BytesPath, FileDescriptorOrPath, GenericPath, ReadableBuffer, StrOrBytesPath, StrPath from asyncio.events import AbstractEventLoop from collections.abc import Sequence +from concurrent.futures import Executor from os import _ScandirIterator, stat_result -from typing import Any, AnyStr, overload +from typing import AnyStr, overload from aiofiles import ospath from aiofiles.ospath import wrap as wrap @@ -41,7 +42,7 @@ async def stat( dir_fd: int | None = None, follow_symlinks: bool = True, loop: AbstractEventLoop | None = ..., - executor: Any = ..., + executor: Executor | None = ..., ) -> stat_result: ... async def rename( src: StrOrBytesPath, @@ -50,10 +51,10 @@ async def rename( src_dir_fd: int | None = None, dst_dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., - executor: Any = ..., + executor: Executor | None = ..., ) -> None: ... async def renames( - old: StrOrBytesPath, new: StrOrBytesPath, loop: AbstractEventLoop | None = ..., executor: Any = ... + old: StrOrBytesPath, new: StrOrBytesPath, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> None: ... async def replace( src: StrOrBytesPath, @@ -62,19 +63,29 @@ async def replace( src_dir_fd: int | None = None, dst_dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., - executor: Any = ..., + executor: Executor | None = ..., ) -> None: ... async def remove( - path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ... + path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> None: ... async def unlink( - path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... + path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> None: ... async def mkdir( - path: StrOrBytesPath, mode: int = 511, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ... + path: StrOrBytesPath, + mode: int = 511, + *, + dir_fd: int | None = None, + loop: AbstractEventLoop | None = ..., + executor: Executor | None = ..., ) -> None: ... async def makedirs( - name: StrOrBytesPath, mode: int = 511, exist_ok: bool = False, *, loop: AbstractEventLoop | None = ..., executor: Any = ... + name: StrOrBytesPath, + mode: int = 511, + exist_ok: bool = False, + *, + loop: AbstractEventLoop | None = ..., + executor: Executor | None = ..., ) -> None: ... async def link( src: StrOrBytesPath, @@ -84,7 +95,7 @@ async def link( dst_dir_fd: int | None = ..., follow_symlinks: bool = ..., loop: AbstractEventLoop | None = ..., - executor: Any = ..., + executor: Executor | None = ..., ) -> None: ... async def symlink( src: StrOrBytesPath, @@ -93,29 +104,35 @@ async def symlink( *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., - executor: Any = ..., + executor: Executor | None = ..., ) -> None: ... async def readlink( - path: AnyStr, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... + path: AnyStr, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> AnyStr: ... async def rmdir( - path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ... + path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> None: ... -async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> None: ... +async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> None: ... @overload -async def scandir(path: None = None, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> _ScandirIterator[str]: ... +async def scandir( + path: None = None, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> _ScandirIterator[str]: ... @overload -async def scandir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> _ScandirIterator[str]: ... +async def scandir( + path: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> _ScandirIterator[str]: ... @overload async def scandir( - path: GenericPath[AnyStr], *, loop: AbstractEventLoop | None = ..., executor: Any = ... + path: GenericPath[AnyStr], *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> _ScandirIterator[AnyStr]: ... @overload -async def listdir(path: StrPath | None, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ... +async def listdir( + path: StrPath | None, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> list[str]: ... @overload -async def listdir(path: BytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[bytes]: ... +async def listdir(path: BytesPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> list[bytes]: ... @overload -async def listdir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ... +async def listdir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> list[str]: ... async def access( path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, effective_ids: bool = False, follow_symlinks: bool = True ) -> bool: ... @@ -126,7 +143,13 @@ if sys.platform != "win32": @overload async def sendfile( - out_fd: int, in_fd: int, offset: int | None, count: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ... + out_fd: int, + in_fd: int, + offset: int | None, + count: int, + *, + loop: AbstractEventLoop | None = ..., + executor: Executor | None = ..., ) -> int: ... @overload async def sendfile( @@ -139,6 +162,6 @@ if sys.platform != "win32": flags: int = ..., *, loop: AbstractEventLoop | None = ..., - executor: Any = ..., + executor: Executor | None = ..., ) -> int: ... # FreeBSD and Mac OS X only async def statvfs(path: FileDescriptorOrPath) -> statvfs_result: ... # Unix only diff --git a/stubs/aiofiles/aiofiles/ospath.pyi b/stubs/aiofiles/aiofiles/ospath.pyi index a586375369fb..efec48722eed 100644 --- a/stubs/aiofiles/aiofiles/ospath.pyi +++ b/stubs/aiofiles/aiofiles/ospath.pyi @@ -1,23 +1,36 @@ from _typeshed import FileDescriptorOrPath from asyncio.events import AbstractEventLoop from collections.abc import Awaitable, Callable +from concurrent.futures import Executor from os import PathLike -from typing import Any, AnyStr, TypeVar +from typing import AnyStr, TypeVar _R = TypeVar("_R") def wrap(func: Callable[..., _R]) -> Callable[..., Awaitable[_R]]: ... -async def exists(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... -async def isfile(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... -async def isdir(s: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... +async def exists( + path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> bool: ... +async def isfile( + path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> bool: ... +async def isdir(s: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> bool: ... async def islink(path: FileDescriptorOrPath) -> bool: ... async def ismount(path: FileDescriptorOrPath) -> bool: ... -async def getsize(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> int: ... -async def getmtime(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ... -async def getatime(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ... -async def getctime(filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ... +async def getsize( + filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> int: ... +async def getmtime( + filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> float: ... +async def getatime( + filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> float: ... +async def getctime( + filename: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... +) -> float: ... async def samefile( - f1: FileDescriptorOrPath, f2: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ... + f1: FileDescriptorOrPath, f2: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ... ) -> bool: ... -async def sameopenfile(fp1: int, fp2: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... +async def sameopenfile(fp1: int, fp2: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> bool: ... async def abspath(path: PathLike[AnyStr] | AnyStr) -> AnyStr: ... diff --git a/stubs/aiofiles/aiofiles/tempfile/__init__.pyi b/stubs/aiofiles/aiofiles/tempfile/__init__.pyi index 87692d844b39..e7ce95b9f5e7 100644 --- a/stubs/aiofiles/aiofiles/tempfile/__init__.pyi +++ b/stubs/aiofiles/aiofiles/tempfile/__init__.pyi @@ -10,6 +10,7 @@ from _typeshed import ( StrPath, ) from asyncio import AbstractEventLoop +from concurrent.futures import Executor from typing import AnyStr, Literal, overload from ..base import AiofilesContextManager @@ -28,7 +29,7 @@ def TemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncTextIOWrapper]: ... # Unbuffered binary: returns a FileIO @@ -42,7 +43,7 @@ def TemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncFileIO]: ... # Buffered binary reading/updating: AsyncBufferedReader @@ -56,7 +57,7 @@ def TemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedReader]: ... # Buffered binary writing: AsyncBufferedIOBase @@ -70,7 +71,7 @@ def TemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedIOBase]: ... # 3.12 added `delete_on_close` @@ -88,7 +89,7 @@ if sys.version_info >= (3, 12): delete: bool = True, delete_on_close: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncTextIOWrapper]: ... # Unbuffered binary: returns a FileIO @@ -104,7 +105,7 @@ if sys.version_info >= (3, 12): delete: bool = True, delete_on_close: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncFileIO]: ... # Buffered binary reading/updating: AsyncBufferedReader @@ -120,7 +121,7 @@ if sys.version_info >= (3, 12): delete: bool = True, delete_on_close: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedReader]: ... # Buffered binary writing: AsyncBufferedIOBase @@ -136,7 +137,7 @@ if sys.version_info >= (3, 12): delete: bool = True, delete_on_close: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedIOBase]: ... else: @@ -152,7 +153,7 @@ else: dir: StrOrBytesPath | None = None, delete: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncTextIOWrapper]: ... # Unbuffered binary: returns a FileIO @@ -167,7 +168,7 @@ else: dir: StrOrBytesPath | None = None, delete: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncFileIO]: ... # Buffered binary reading/updating: AsyncBufferedReader @@ -182,7 +183,7 @@ else: dir: StrOrBytesPath | None = None, delete: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedReader]: ... # Buffered binary writing: AsyncBufferedIOBase @@ -197,7 +198,7 @@ else: dir: StrOrBytesPath | None = None, delete: bool = True, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedIOBase]: ... # Text mode: always returns AsyncTextIOWrapper @@ -213,7 +214,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncTextIOWrapper]: ... @overload def SpooledTemporaryFile( @@ -226,7 +227,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncTextIOWrapper]: ... # Unbuffered binary: returns a FileIO @@ -242,7 +243,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncFileIO]: ... @overload def SpooledTemporaryFile( @@ -255,7 +256,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncFileIO]: ... # Buffered binary reading/updating: AsyncBufferedReader @@ -270,7 +271,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedReader]: ... # Buffered binary writing: AsyncBufferedIOBase @@ -286,7 +287,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedIOBase]: ... @overload def SpooledTemporaryFile( @@ -299,7 +300,7 @@ def SpooledTemporaryFile( prefix: AnyStr | None = None, dir: StrOrBytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManager[AsyncBufferedIOBase]: ... @overload def TemporaryDirectory( @@ -307,7 +308,7 @@ def TemporaryDirectory( prefix: str | None = None, dir: StrPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManagerTempDir: ... @overload def TemporaryDirectory( @@ -315,7 +316,7 @@ def TemporaryDirectory( prefix: bytes | None = None, dir: BytesPath | None = None, loop: AbstractEventLoop | None = None, - executor=None, + executor: Executor | None = None, ) -> AiofilesContextManagerTempDir: ... class AiofilesContextManagerTempDir(AiofilesContextManager[AsyncTemporaryDirectory]): diff --git a/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi b/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi index 23abf5cbe796..b6f05e13c7ce 100644 --- a/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi +++ b/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete, OpenBinaryMode +from _typeshed import Incomplete, OpenBinaryMode, ReadableBuffer from asyncio import AbstractEventLoop from collections.abc import Generator, Iterable +from concurrent.futures import Executor from tempfile import TemporaryDirectory from typing import TypeVar @@ -14,16 +15,14 @@ from aiofiles.threadpool.utils import ( _T = TypeVar("_T") class AsyncSpooledTemporaryFile(AsyncBase[_T]): - def fileno(self) -> Generator[Incomplete, Incomplete, Incomplete]: ... - def rollover(self) -> Generator[Incomplete, Incomplete, Incomplete]: ... + def fileno(self) -> Generator[Incomplete]: ... + def rollover(self) -> Generator[Incomplete]: ... async def close(self) -> None: ... async def flush(self) -> None: ... async def isatty(self) -> bool: ... - # All must return `AnyStr`: - async def read(self, n: int = ..., /): ... - async def readline(self, limit: int | None = ..., /): ... - async def readlines(self, hint: int = ..., /) -> list[Incomplete]: ... - # --- + async def read(self, n: int = ..., /) -> str | bytes: ... + async def readline(self, limit: int | None = ..., /) -> str | bytes: ... + async def readlines(self, hint: int = ..., /) -> list[str | bytes]: ... async def seek(self, offset: int, whence: int = ...) -> int: ... async def tell(self) -> int: ... async def truncate(self, size: int | None = ...) -> None: ... @@ -34,18 +33,17 @@ class AsyncSpooledTemporaryFile(AsyncBase[_T]): @property def mode(self) -> OpenBinaryMode: ... @property - def name(self) -> str: ... + def name(self) -> str | bytes: ... @property def newlines(self) -> str: ... - # Both should work with `AnyStr`, like in `tempfile`: - async def write(self, s) -> int: ... - async def writelines(self, iterable: Iterable[Incomplete]) -> None: ... + async def write(self, s: str | bytes | ReadableBuffer) -> int: ... + async def writelines(self, iterable: Iterable[str | bytes | ReadableBuffer]) -> None: ... class AsyncTemporaryDirectory: async def cleanup(self) -> None: ... @property - def name(self): ... # should be `AnyStr` + def name(self) -> str | bytes: ... def __init__( - self, file: TemporaryDirectory[Incomplete], loop: AbstractEventLoop | None, executor: Incomplete | None + self, file: TemporaryDirectory[Incomplete], loop: AbstractEventLoop | None, executor: Executor | None ) -> None: ... async def close(self) -> None: ...