-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add missing methods methods in aiofiles #4734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
4a404c0
63013ee
a1530cd
18efc0e
e43b9a3
bf543a3
d5fd6ac
d8d8959
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer | ||
from io import FileIO | ||
from typing import Generic, Iterable, List, Optional, TypeVar, Union | ||
|
||
from ..base import AsyncBase | ||
|
||
class AsyncBufferedIOBase(AsyncBase[bytes]): ... | ||
class AsyncBufferedReader(AsyncBufferedIOBase): ... | ||
class AsyncFileIO(AsyncBase[bytes]): ... | ||
_FileName = TypeVar("_FileName", bound=Union[AnyPath, int]) | ||
|
||
class _UnknownAsyncBinaryIO(AsyncBase[bytes], Generic[_FileName]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure making this generic over _Filename is worth it; it's slightly more precise for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is it true? I use pyright and it doesn't complain about not setting a generic type. async def(file: AsyncTextIOWrapper):
name = file.name
# name is auto-detected to be of type: str | bytes | _PathLike[str] | _PathLike[bytes] | int Of course, if other type checkers complain, I can annotate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mypy does this if you use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, removed that. |
||
async def close(self) -> None: ... | ||
async def flush(self) -> None: ... | ||
async def isatty(self) -> bool: ... | ||
async def read(self, __size: int = ...) -> Optional[bytes]: ... | ||
async def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ... | ||
async def readline(self, __size: Optional[int] = ...) -> 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 writable(self) -> bool: ... | ||
async def write(self, __b: ReadableBuffer) -> Optional[int]: ... | ||
async def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ... | ||
def fileno(self) -> int: ... | ||
def readable(self) -> bool: ... | ||
@property | ||
def closed(self) -> bool: ... | ||
@property | ||
def mode(self) -> str: ... | ||
@property | ||
def name(self) -> _FileName: ... | ||
|
||
class AsyncBufferedIOBase(_UnknownAsyncBinaryIO[_FileName]): | ||
async def read1(self, __size: int = ...) -> bytes: ... | ||
def detach(self) -> FileIO: ... | ||
@property | ||
def raw(self) -> FileIO: ... | ||
|
||
class AsyncBufferedReader(AsyncBufferedIOBase[_FileName]): | ||
async def peek(self, __size: int = ...) -> bytes: ... | ||
|
||
class AsyncFileIO(_UnknownAsyncBinaryIO[_FileName]): | ||
async def readall(self) -> bytes: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
from _typeshed import AnyPath | ||
from typing import BinaryIO, Generic, Iterable, List, Optional, Tuple, TypeVar, Union | ||
|
||
from ..base import AsyncBase | ||
|
||
class AsyncTextIOWrapper(AsyncBase[str]): ... | ||
_FileName = TypeVar("_FileName", bound=Union[AnyPath, int]) | ||
|
||
class AsyncTextIOWrapper(AsyncBase[str], Generic[_FileName]): | ||
async def close(self) -> None: ... | ||
async def flush(self) -> None: ... | ||
async def isatty(self) -> bool: ... | ||
async def read(self, __size: int = ...) -> str: ... | ||
async def readline(self, __size: Optional[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 writable(self) -> bool: ... | ||
async def write(self, __b: str) -> Optional[int]: ... | ||
async def writelines(self, __lines: Iterable[str]) -> None: ... | ||
def detach(self) -> BinaryIO: ... | ||
def fileno(self) -> int: ... | ||
def readable(self) -> bool: ... | ||
@property | ||
def buffer(self) -> BinaryIO: ... | ||
@property | ||
def closed(self) -> bool: ... | ||
@property | ||
def encoding(self) -> str: ... | ||
@property | ||
def errors(self) -> Optional[str]: ... | ||
@property | ||
def line_buffering(self) -> bool: ... | ||
@property | ||
def newlines(self) -> Union[str, Tuple[str, ...], None]: ... | ||
@property | ||
def name(self) -> _FileName: ... | ||
@property | ||
def mode(self) -> str: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove these arguments from some overloads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a mistake. Pushed a fix.