mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-09 11:11:26 +08:00
AnyStr cleanup (#5487)
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs. * Add StrOrBytesPath as preferred alias for AnyPath. * Replace all remaining AnyPath instances with StrOrBytesPath. * Mark AnyPath as obsolete. Part of #5470
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import sys
|
||||
from _typeshed import AnyPath
|
||||
from _typeshed import StrOrBytesPath
|
||||
from os import stat_result
|
||||
from typing import Optional, Sequence, Union, overload
|
||||
|
||||
_FdOrAnyPath = Union[int, AnyPath]
|
||||
_FdOrAnyPath = Union[int, StrOrBytesPath]
|
||||
|
||||
async def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
|
||||
async def rename(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def remove(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def mkdir(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def rmdir(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
|
||||
async def rename(
|
||||
src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...
|
||||
) -> 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: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
@overload
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
from _typeshed import AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode
|
||||
from _typeshed import (
|
||||
OpenBinaryMode,
|
||||
OpenBinaryModeReading,
|
||||
OpenBinaryModeUpdating,
|
||||
OpenBinaryModeWriting,
|
||||
OpenTextMode,
|
||||
StrOrBytesPath,
|
||||
)
|
||||
from asyncio import AbstractEventLoop
|
||||
from typing import Any, Callable, Optional, Union, overload
|
||||
from typing_extensions import Literal
|
||||
@@ -7,7 +14,7 @@ from ..base import AiofilesContextManager
|
||||
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, _UnknownAsyncBinaryIO
|
||||
from .text import AsyncTextIOWrapper
|
||||
|
||||
_OpenFile = Union[AnyPath, int]
|
||||
_OpenFile = Union[StrOrBytesPath, int]
|
||||
_Opener = Callable[[str, int], int]
|
||||
|
||||
# Text mode: always returns AsyncTextIOWrapper
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer
|
||||
from io import FileIO
|
||||
from typing import Iterable, List, Optional, Union
|
||||
|
||||
@@ -26,7 +26,7 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
@property
|
||||
def name(self) -> Union[AnyPath, int]: ...
|
||||
def name(self) -> Union[StrOrBytesPath, int]: ...
|
||||
|
||||
class AsyncBufferedIOBase(_UnknownAsyncBinaryIO):
|
||||
async def read1(self, __size: int = ...) -> bytes: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from _typeshed import AnyPath
|
||||
from _typeshed import StrOrBytesPath
|
||||
from typing import BinaryIO, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
from ..base import AsyncBase
|
||||
@@ -33,6 +33,6 @@ class AsyncTextIOWrapper(AsyncBase[str]):
|
||||
@property
|
||||
def newlines(self) -> Union[str, Tuple[str, ...], None]: ...
|
||||
@property
|
||||
def name(self) -> Union[AnyPath, int]: ...
|
||||
def name(self) -> Union[StrOrBytesPath, int]: ...
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user