[aiofiles] Remove from pyrightconfig (#14310)

This commit is contained in:
Semyon Moroz
2025-07-07 14:29:38 +02:00
committed by GitHub
parent 98844c3ba9
commit e27ad6d19b
6 changed files with 110 additions and 72 deletions
+6 -2
View File
@@ -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: ...
+47 -24
View File
@@ -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: ...
@overload
async def scandir(path: None = None, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> _ScandirIterator[str]: ...
@overload
async def scandir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> _ScandirIterator[str]: ...
async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...) -> None: ...
@overload
async def scandir(
path: GenericPath[AnyStr], *, loop: AbstractEventLoop | None = ..., executor: Any = ...
path: None = None, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> _ScandirIterator[str]: ...
@overload
async def scandir(
path: int, *, loop: AbstractEventLoop | None = ..., executor: Executor | None = ...
) -> _ScandirIterator[str]: ...
@overload
async def scandir(
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
+23 -10
View File
@@ -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: ...
+22 -21
View File
@@ -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
@@ -27,7 +28,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
@@ -41,7 +42,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
@@ -55,7 +56,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
@@ -69,7 +70,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`
@@ -87,7 +88,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
@@ -103,7 +104,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
@@ -119,7 +120,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
@@ -135,7 +136,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:
@@ -151,7 +152,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
@@ -166,7 +167,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
@@ -181,7 +182,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
@@ -196,7 +197,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
@@ -212,7 +213,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(
@@ -225,7 +226,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
@@ -241,7 +242,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(
@@ -254,7 +255,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
@@ -269,7 +270,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
@@ -285,7 +286,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(
@@ -298,7 +299,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(
@@ -306,7 +307,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(
@@ -314,7 +315,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[str]):
+12 -14
View File
@@ -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: ...