Skip to content

Complete stubtest for aiofiles + fix on Windows #9184

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

Merged
merged 4 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions stubs/aiofiles/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Some arguments only exist on FreeBSD and MacOS
aiofiles.os.sendfile

# These all delegate using *args,**kwargs, but stubs use signature of
# method they are being delegated to.
aiofiles.threadpool.binary.AsyncBufferedIOBase.close
Expand Down Expand Up @@ -51,6 +48,7 @@ aiofiles.ospath.samefile
aiofiles.ospath.sameopenfile

# Same issues as above
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.close
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.fileno
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.flush
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.isatty
Expand All @@ -61,3 +59,7 @@ aiofiles.tempfile.temptypes.AsyncTemporaryDirectory.cleanup
# Metaclass differs:
aiofiles.base.AiofilesContextManager
aiofiles.tempfile.AiofilesContextManagerTempDir

# Helper decorator, too complex to type
aiofiles.os.wrap

2 changes: 2 additions & 0 deletions stubs/aiofiles/@tests/stubtest_allowlist_darwin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This function gets the wrong signature from functools.wraps()
aiofiles.os.sendfile
2 changes: 2 additions & 0 deletions stubs/aiofiles/@tests/stubtest_allowlist_linux.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This function gets the wrong signature from functools.wraps()
aiofiles.os.sendfile
5 changes: 5 additions & 0 deletions stubs/aiofiles/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
version = "22.1.*"

[tool.stubtest]
ignore_missing_stub = false
# linux and darwin are equivalent
platforms = ["linux", "win32"]
2 changes: 1 addition & 1 deletion stubs/aiofiles/aiofiles/os.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from os import stat_result
from typing import Any, overload
from typing_extensions import TypeAlias

from . import ospath
from aiofiles import ospath

path = ospath

Expand Down
7 changes: 5 additions & 2 deletions stubs/aiofiles/aiofiles/tempfile/temptypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ from tempfile import TemporaryDirectory, _BytesMode
from types import coroutine as coroutine
from typing import TypeVar

from ..base import AsyncBase as AsyncBase
from ..threadpool.utils import (
from aiofiles.base import AsyncBase as AsyncBase
from aiofiles.threadpool.utils import (
cond_delegate_to_executor as cond_delegate_to_executor,
delegate_to_executor as delegate_to_executor,
proxy_property_directly as proxy_property_directly,
Expand All @@ -17,6 +17,7 @@ _T = TypeVar("_T")
class AsyncSpooledTemporaryFile(AsyncBase[_T]):
def fileno(self) -> Generator[Incomplete, Incomplete, Incomplete]: ...
def rollover(self) -> Generator[Incomplete, Incomplete, Incomplete]: ...
async def close(self) -> None: ...
async def flush(self) -> None: ...
async def isatty(self) -> bool: ...
# All must return `AnyStr`:
Expand All @@ -37,6 +38,8 @@ class AsyncSpooledTemporaryFile(AsyncBase[_T]):
def name(self) -> str: ...
@property
def newlines(self) -> str: ...
@property
def softspace(self) -> bool: ...
# Both should work with `AnyStr`, like in `tempfile`:
async def write(self, s: Incomplete) -> int: ...
async def writelines(self, iterable: Iterable[Incomplete]) -> None: ...
Expand Down