mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Use _typeshed.FileDescriptorOrPath in stubs (#9695)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from _typeshed import Incomplete, StrOrBytesPath, SupportsRead
|
||||
from _typeshed import FileDescriptorOrPath, Incomplete, SupportsRead
|
||||
from typing import Any, Protocol
|
||||
from typing_extensions import Literal
|
||||
|
||||
@@ -109,7 +109,7 @@ class TransposedFont:
|
||||
def getsize(self, text: str | bytes, *args, **kwargs) -> tuple[int, int]: ...
|
||||
def getmask(self, text: str | bytes, mode: str = ..., *args, **kwargs): ...
|
||||
|
||||
def load(filename: StrOrBytesPath | int) -> ImageFont: ...
|
||||
def load(filename: FileDescriptorOrPath) -> ImageFont: ...
|
||||
def truetype(
|
||||
font: str | bytes | SupportsRead[bytes] | None = ...,
|
||||
size: int = ...,
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
from _typeshed import Incomplete, StrOrBytesPath, StrPath
|
||||
from _typeshed import FileDescriptorOrPath, Incomplete, StrPath
|
||||
from collections.abc import Iterator
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from pygments.lexer import Lexer, LexerMeta
|
||||
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | int # copy/pasted from builtins.pyi
|
||||
|
||||
def get_all_lexers(plugins: bool = ...) -> Iterator[tuple[str, tuple[str, ...], tuple[str, ...], tuple[str, ...]]]: ...
|
||||
def find_lexer_class(name: str) -> LexerMeta | None: ...
|
||||
def find_lexer_class_by_name(_alias: str) -> LexerMeta: ...
|
||||
def get_lexer_by_name(_alias: str, **options: Any) -> Lexer: ...
|
||||
def load_lexer_from_file(filename: _OpenFile, lexername: str = ..., **options: Any) -> Lexer: ...
|
||||
def load_lexer_from_file(filename: FileDescriptorOrPath, lexername: str = ..., **options: Any) -> Lexer: ...
|
||||
def find_lexer_class_for_filename(_fn: StrPath, code: str | bytes | None = ...) -> LexerMeta | None: ...
|
||||
def get_lexer_for_filename(_fn: StrPath, code: str | bytes | None = ..., **options: Any) -> Lexer: ...
|
||||
def get_lexer_for_mimetype(_mime: str, **options: Any) -> Lexer: ...
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
import sys
|
||||
from _typeshed import GenericPath, StrOrBytesPath
|
||||
from _typeshed import FileDescriptorOrPath, GenericPath, StrOrBytesPath
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from collections.abc import Sequence
|
||||
from os import _ScandirIterator, stat_result
|
||||
from typing import Any, AnyStr, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from aiofiles import ospath
|
||||
|
||||
path = ospath
|
||||
|
||||
_FdOrAnyPath: TypeAlias = int | StrOrBytesPath
|
||||
|
||||
async def stat(
|
||||
path: _FdOrAnyPath,
|
||||
path: FileDescriptorOrPath,
|
||||
*,
|
||||
dir_fd: int | None = ...,
|
||||
follow_symlinks: bool = ...,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from _typeshed import FileDescriptorOrPath
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from typing import Any
|
||||
|
||||
async def exists(path: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
|
||||
async def isfile(path: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
|
||||
async def isdir(s: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
|
||||
async def getsize(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> int: ...
|
||||
async def getmtime(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ...
|
||||
async def getatime(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ...
|
||||
async def getctime(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ...
|
||||
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 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 samefile(
|
||||
f1: StrOrBytesPath | int, f2: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
|
||||
f1: FileDescriptorOrPath, f2: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
|
||||
) -> bool: ...
|
||||
async def sameopenfile(fp1: int, fp2: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
from _typeshed import (
|
||||
FileDescriptorOrPath,
|
||||
Incomplete,
|
||||
OpenBinaryMode,
|
||||
OpenBinaryModeReading,
|
||||
OpenBinaryModeUpdating,
|
||||
OpenBinaryModeWriting,
|
||||
OpenTextMode,
|
||||
StrOrBytesPath,
|
||||
)
|
||||
from asyncio import AbstractEventLoop
|
||||
from collections.abc import Callable
|
||||
@@ -16,13 +16,12 @@ from ..base import AiofilesContextManager
|
||||
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, _UnknownAsyncBinaryIO
|
||||
from .text import AsyncTextIOWrapper
|
||||
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | int
|
||||
_Opener: TypeAlias = Callable[[str, int], int]
|
||||
|
||||
# Text mode: always returns AsyncTextIOWrapper
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
file: FileDescriptorOrPath,
|
||||
mode: OpenTextMode = ...,
|
||||
buffering: int = ...,
|
||||
encoding: str | None = ...,
|
||||
@@ -38,7 +37,7 @@ def open(
|
||||
# Unbuffered binary: returns a FileIO
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
file: FileDescriptorOrPath,
|
||||
mode: OpenBinaryMode,
|
||||
buffering: Literal[0],
|
||||
encoding: None = ...,
|
||||
@@ -54,7 +53,7 @@ def open(
|
||||
# Buffered binary reading/updating: AsyncBufferedReader
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
file: FileDescriptorOrPath,
|
||||
mode: OpenBinaryModeReading | OpenBinaryModeUpdating,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
@@ -70,7 +69,7 @@ def open(
|
||||
# Buffered binary writing: AsyncBufferedIOBase
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
file: FileDescriptorOrPath,
|
||||
mode: OpenBinaryModeWriting,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
@@ -86,7 +85,7 @@ def open(
|
||||
# Buffering cannot be determined: fall back to _UnknownAsyncBinaryIO
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
file: FileDescriptorOrPath,
|
||||
mode: OpenBinaryMode,
|
||||
buffering: int = ...,
|
||||
encoding: None = ...,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
|
||||
from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
|
||||
from collections.abc import Iterable
|
||||
from io import FileIO
|
||||
|
||||
@@ -26,7 +26,7 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
@property
|
||||
def name(self) -> StrOrBytesPath | int: ...
|
||||
def name(self) -> FileDescriptorOrPath: ...
|
||||
|
||||
class AsyncBufferedIOBase(_UnknownAsyncBinaryIO):
|
||||
async def read1(self, __size: int = ...) -> bytes: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from _typeshed import FileDescriptorOrPath
|
||||
from collections.abc import Iterable
|
||||
from typing import BinaryIO
|
||||
|
||||
@@ -34,6 +34,6 @@ class AsyncTextIOWrapper(AsyncBase[str]):
|
||||
@property
|
||||
def newlines(self) -> str | tuple[str, ...] | None: ...
|
||||
@property
|
||||
def name(self) -> StrOrBytesPath | int: ...
|
||||
def name(self) -> FileDescriptorOrPath: ...
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
from _typeshed import StrOrBytesPath
|
||||
from _typeshed import FileDescriptorOrPath
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | int
|
||||
|
||||
def main(template: _OpenFile, data: _OpenFile | None = ..., **kwargs: Any) -> str: ...
|
||||
def main(template: FileDescriptorOrPath, data: FileDescriptorOrPath | None = ..., **kwargs: Any) -> str: ...
|
||||
def cli_main() -> None: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import _csv
|
||||
from _typeshed import StrOrBytesPath
|
||||
from _typeshed import FileDescriptorOrPath, StrOrBytesPath
|
||||
from collections.abc import Iterable
|
||||
from typing import Any, BinaryIO, TextIO
|
||||
from typing_extensions import TypeAlias
|
||||
@@ -12,21 +12,21 @@ IAB_INDEX: _INDEX
|
||||
|
||||
class FileIndexer(Subscriber):
|
||||
writer: _csv._writer
|
||||
def __init__(self, index_file: TextIO | StrOrBytesPath | int) -> None: ...
|
||||
def __init__(self, index_file: TextIO | FileDescriptorOrPath) -> None: ...
|
||||
def update(self, data: Iterable[Any]) -> None: ...
|
||||
|
||||
class OUIIndexParser(Publisher):
|
||||
fh: BinaryIO
|
||||
def __init__(self, ieee_file: BinaryIO | StrOrBytesPath | int) -> None: ...
|
||||
def __init__(self, ieee_file: BinaryIO | FileDescriptorOrPath) -> None: ...
|
||||
def parse(self) -> None: ...
|
||||
|
||||
class IABIndexParser(Publisher):
|
||||
fh: BinaryIO
|
||||
def __init__(self, ieee_file: BinaryIO | StrOrBytesPath | int) -> None: ...
|
||||
def __init__(self, ieee_file: BinaryIO | FileDescriptorOrPath) -> None: ...
|
||||
def parse(self) -> None: ...
|
||||
|
||||
def create_index_from_registry(
|
||||
registry_fh: BinaryIO | StrOrBytesPath | int, index_path: StrOrBytesPath, parser: type[OUIIndexParser] | type[IABIndexParser]
|
||||
registry_fh: BinaryIO | FileDescriptorOrPath, index_path: StrOrBytesPath, parser: type[OUIIndexParser] | type[IABIndexParser]
|
||||
) -> None: ...
|
||||
def create_indices() -> None: ...
|
||||
def load_index(index: _INDEX, fp: Iterable[bytes]) -> None: ...
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# https://pyinstaller.org/en/stable/hooks.html#module-PyInstaller.compat
|
||||
from _typeshed import FileDescriptor, GenericPath, StrOrBytesPath
|
||||
from _typeshed import FileDescriptorOrPath, GenericPath
|
||||
from collections.abc import Iterable
|
||||
from types import ModuleType
|
||||
from typing import AnyStr, overload
|
||||
from typing_extensions import Final, Literal, TypeAlias
|
||||
|
||||
_OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor
|
||||
from typing_extensions import Final, Literal
|
||||
|
||||
strict_collect_mode: bool
|
||||
is_64bits: Final[bool]
|
||||
@@ -48,7 +46,7 @@ architecture: Final[Literal["64bit", "n32bit", "32bit"]]
|
||||
system: Final[Literal["Cygwin", "Linux", "Darwin", "Java", "Windows"]]
|
||||
machine: Final[Literal["sw_64", "loongarch64", "arm", "intel", "ppc", "mips", "riscv", "s390x", "unknown", None]]
|
||||
|
||||
def is_wine_dll(filename: _OpenFile) -> bool: ...
|
||||
def is_wine_dll(filename: FileDescriptorOrPath) -> bool: ...
|
||||
@overload
|
||||
def getenv(name: str, default: str) -> str: ...
|
||||
@overload
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from _typeshed import FileDescriptor, StrOrBytesPath
|
||||
from collections.abc import Callable
|
||||
from typing import TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
@@ -9,4 +8,3 @@ from Xlib.protocol.rq import Request
|
||||
_T = TypeVar("_T")
|
||||
ErrorHandler: TypeAlias = Callable[[XError, Request | None], _T]
|
||||
Unused: TypeAlias = object
|
||||
OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from Xlib._typing import OpenFile
|
||||
from _typeshed import FileDescriptorOrPath
|
||||
|
||||
FamilyInternet: int
|
||||
FamilyDECnet: int
|
||||
@@ -9,7 +9,7 @@ FamilyLocal: int
|
||||
|
||||
class Xauthority:
|
||||
entries: list[tuple[bytes, bytes, bytes, bytes, bytes]]
|
||||
def __init__(self, filename: OpenFile | None = ...) -> None: ...
|
||||
def __init__(self, filename: FileDescriptorOrPath | None = ...) -> None: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __getitem__(self, i: int) -> tuple[bytes, bytes, bytes, bytes, bytes]: ...
|
||||
def get_best_auth(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import StrOrBytesPath, SupportsWrite
|
||||
from _typeshed import FileDescriptorOrPath, SupportsWrite
|
||||
from collections.abc import Iterable, Mapping
|
||||
from distutils.cmd import Command
|
||||
from typing import IO, Any
|
||||
|
||||
class DistributionMetadata:
|
||||
def __init__(self, path: int | StrOrBytesPath | None = ...) -> None: ...
|
||||
def __init__(self, path: FileDescriptorOrPath | None = ...) -> None: ...
|
||||
name: str | None
|
||||
version: str | None
|
||||
author: str | None
|
||||
|
||||
Reference in New Issue
Block a user