Skip to content

Commit 10f05d3

Browse files
authored
Remove aiofiles/tempfile/temptypes.pyi from pyright exclude (#9104)
1 parent 0e1ca27 commit 10f05d3

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

pyrightconfig.stricter.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"stdlib/xml/dom/minidom.pyi",
2222
"stdlib/xml/dom/pulldom.pyi",
2323
"stdlib/xml/sax",
24-
"stubs/aiofiles/aiofiles/tempfile/temptypes.pyi",
2524
"stubs/aiofiles/aiofiles/threadpool/utils.pyi",
2625
"stubs/annoy/annoy/annoylib.pyi",
2726
"stubs/aws-xray-sdk",

stubs/aiofiles/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ aiofiles.ospath.sameopenfile
5454
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.fileno
5555
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.flush
5656
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.isatty
57-
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.newlines
5857
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.rollover
5958
aiofiles.tempfile.temptypes.AsyncSpooledTemporaryFile.tell
6059
aiofiles.tempfile.temptypes.AsyncTemporaryDirectory.cleanup
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from _typeshed import Incomplete
22
from asyncio import AbstractEventLoop
3-
from collections.abc import Generator
3+
from collections.abc import Generator, Iterable
4+
from tempfile import TemporaryDirectory, _BytesMode
45
from types import coroutine as coroutine
56
from typing import TypeVar
67

@@ -18,29 +19,33 @@ class AsyncSpooledTemporaryFile(AsyncBase[_T]):
1819
def rollover(self) -> Generator[Incomplete, Incomplete, Incomplete]: ...
1920
async def flush(self) -> None: ...
2021
async def isatty(self) -> bool: ...
21-
async def read(self, __n: int = ...): ...
22-
async def readline(self, __limit: int | None = ...): ...
23-
async def readlines(self, __hint: int = ...): ...
22+
# All must return `AnyStr`:
23+
async def read(self, __n: int = ...) -> Incomplete: ...
24+
async def readline(self, __limit: int | None = ...) -> Incomplete: ...
25+
async def readlines(self, __hint: int = ...) -> list[Incomplete]: ...
26+
# ---
2427
async def seek(self, offset: int, whence: int = ...) -> int: ...
2528
async def tell(self) -> int: ...
2629
async def truncate(self, size: int | None = ...) -> None: ...
2730
@property
28-
def closed(self): ...
31+
def closed(self) -> bool: ...
2932
@property
30-
def encoding(self): ...
33+
def encoding(self) -> str: ...
3134
@property
32-
def mode(self): ...
35+
def mode(self) -> _BytesMode: ...
3336
@property
34-
def name(self): ...
35-
async def newlines(self): ...
37+
def name(self) -> str: ...
3638
@property
37-
def softspace(self): ...
38-
async def write(self, s): ...
39-
async def writelines(self, iterable): ...
39+
def newlines(self) -> str: ...
40+
# Both should work with `AnyStr`, like in `tempfile`:
41+
async def write(self, s: Incomplete) -> int: ...
42+
async def writelines(self, iterable: Iterable[Incomplete]) -> None: ...
4043

4144
class AsyncTemporaryDirectory:
4245
async def cleanup(self) -> None: ...
4346
@property
44-
def name(self): ...
45-
def __init__(self, file, loop: AbstractEventLoop | None, executor: Incomplete | None) -> None: ...
47+
def name(self) -> Incomplete: ... # should be `AnyStr`
48+
def __init__(
49+
self, file: TemporaryDirectory[Incomplete], loop: AbstractEventLoop | None, executor: Incomplete | None
50+
) -> None: ...
4651
async def close(self) -> None: ...
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
from collections.abc import Callable
12
from types import coroutine as coroutine
3+
from typing import TypeVar
24

3-
def delegate_to_executor(*attrs): ...
4-
def proxy_method_directly(*attrs): ...
5-
def proxy_property_directly(*attrs): ...
6-
def cond_delegate_to_executor(*attrs): ...
5+
_T = TypeVar("_T", bound=type)
6+
7+
# All these function actually mutate the given type:
8+
def delegate_to_executor(*attrs: str) -> Callable[[_T], _T]: ...
9+
def proxy_method_directly(*attrs: str) -> Callable[[_T], _T]: ...
10+
def proxy_property_directly(*attrs: str) -> Callable[[_T], _T]: ...
11+
def cond_delegate_to_executor(*attrs: str) -> Callable[[_T], _T]: ...

0 commit comments

Comments
 (0)