From 6767315d6eda82af6fd408195502b3db6e0fc9e7 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 5 Mar 2022 14:15:25 +0000 Subject: [PATCH 01/17] stdlib: Add several missing `@abstractmethod` decorators --- stdlib/contextlib.pyi | 11 ++++++++--- stdlib/mmap.pyi | 4 ++++ stdlib/multiprocessing/synchronize.pyi | 9 ++++++++- stdlib/numbers.pyi | 3 +++ stdlib/os/__init__.pyi | 6 ++++++ stdlib/pathlib.pyi | 1 + stdlib/typing.pyi | 2 ++ 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 4795aac67c23..3bc06bc669cf 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -148,6 +148,7 @@ _SupportsCloseT = TypeVar("_SupportsCloseT", bound=_SupportsClose) class closing(AbstractContextManager[_SupportsCloseT]): def __init__(self, thing: _SupportsCloseT) -> None: ... + def __exit__(self, *exc_info: object) -> None: ... if sys.version_info >= (3, 10): class _SupportsAclose(Protocol): @@ -156,6 +157,7 @@ if sys.version_info >= (3, 10): class aclosing(AbstractAsyncContextManager[_SupportsAcloseT]): def __init__(self, thing: _SupportsAcloseT) -> None: ... + async def __aexit__(self, *exc_info: object) -> None: ... class suppress(AbstractContextManager[None]): def __init__(self, *exceptions: type[BaseException]) -> None: ... @@ -163,11 +165,14 @@ class suppress(AbstractContextManager[None]): self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> bool: ... -class redirect_stdout(AbstractContextManager[_T_io]): +class _RedirectStream(AbstractContextManager[_T_io]): def __init__(self, new_target: _T_io) -> None: ... + def __exit__( + self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None + ) -> None: ... -class redirect_stderr(AbstractContextManager[_T_io]): - def __init__(self, new_target: _T_io) -> None: ... +class redirect_stdout(_RedirectStream): ... +class redirect_stderr(_RedirectStream): ... class ExitStack(AbstractContextManager[ExitStack]): def __init__(self) -> None: ... diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 5dd266e84607..e45987ca8a82 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,6 +1,7 @@ import sys from _typeshed import ReadableBuffer from contextlib import AbstractContextManager +from types import TracebackType from typing import Iterable, Iterator, NoReturn, Sized, overload ACCESS_DEFAULT: int @@ -70,6 +71,9 @@ class mmap(AbstractContextManager[mmap], Iterable[int], Sized): # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and # __len__, so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[int]: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... if sys.version_info >= (3, 8) and sys.platform != "win32": MADV_NORMAL: int diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 6764b7666152..d100a0d2d214 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -2,6 +2,7 @@ import sys import threading from contextlib import AbstractContextManager from multiprocessing.context import BaseContext +from types import TracebackType from typing import Any, Callable, Union __all__ = ["Lock", "RLock", "Semaphore", "BoundedSemaphore", "Condition", "Event"] @@ -28,8 +29,11 @@ class Condition(AbstractContextManager[bool]): def wait_for(self, predicate: Callable[[], bool], timeout: float | None = ...) -> bool: ... def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ... def release(self) -> None: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... -class Event(AbstractContextManager[bool]): +class Event: def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ... def is_set(self) -> bool: ... def set(self) -> None: ... @@ -49,3 +53,6 @@ class Semaphore(SemLock): class SemLock(AbstractContextManager[bool]): def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ... def release(self) -> None: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... diff --git a/stdlib/numbers.pyi b/stdlib/numbers.pyi index 7c0c95853741..d94ae7faf890 100644 --- a/stdlib/numbers.pyi +++ b/stdlib/numbers.pyi @@ -42,8 +42,11 @@ class Complex(Number): def __pow__(self, exponent: Any) -> Any: ... @abstractmethod def __rpow__(self, base: Any) -> Any: ... + @abstractmethod def __abs__(self) -> Real: ... + @abstractmethod def conjugate(self) -> Any: ... + @abstractmethod def __eq__(self, other: object) -> bool: ... class Real(Complex, SupportsFloat): diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index d38148e7921f..f156e8ed4383 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -12,10 +12,12 @@ from _typeshed import ( StrPath, structseq, ) +from abc import abstractmethod from builtins import OSError from contextlib import AbstractContextManager from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper as _TextIOWrapper from subprocess import Popen +from types import TracebackType from typing import ( IO, Any, @@ -371,6 +373,7 @@ class stat_result(structseq[float], tuple[int, int, int, int, int, int, int, flo @runtime_checkable class PathLike(Protocol[_AnyStr_co]): + @abstractmethod def __fspath__(self) -> _AnyStr_co: ... @overload @@ -722,6 +725,9 @@ def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... + def __exit__( + self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + ) -> bool | None: ... def close(self) -> None: ... if sys.version_info >= (3, 7): diff --git a/stdlib/pathlib.pyi b/stdlib/pathlib.pyi index fc5d7d8fb7e1..eead11dd310b 100644 --- a/stdlib/pathlib.pyi +++ b/stdlib/pathlib.pyi @@ -39,6 +39,7 @@ class PurePath(PathLike[str]): def __new__(cls: type[Self], *args: StrPath) -> Self: ... def __hash__(self) -> int: ... def __eq__(self, other: object) -> bool: ... + def __fspath__(self) -> str: ... def __lt__(self, other: PurePath) -> bool: ... def __le__(self, other: PurePath) -> bool: ... def __gt__(self, other: PurePath) -> bool: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 08fb6d5b433b..a874a0ddd25c 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -902,6 +902,7 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): @runtime_checkable class ContextManager(Protocol[_T_co]): def __enter__(self) -> _T_co: ... + @abstractmethod def __exit__( self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool | None: ... @@ -909,6 +910,7 @@ class ContextManager(Protocol[_T_co]): @runtime_checkable class AsyncContextManager(Protocol[_T_co]): async def __aenter__(self) -> _T_co: ... + @abstractmethod async def __aexit__( self, __exc_type: Type[BaseException] | None, __exc_value: BaseException | None, __traceback: TracebackType | None ) -> bool | None: ... From cd862ea93c01ac28423160393a235bbb9d952a80 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 5 Mar 2022 14:25:03 +0000 Subject: [PATCH 02/17] Update contextlib.pyi --- stdlib/contextlib.pyi | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 3bc06bc669cf..6ad25b468243 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -117,8 +117,14 @@ if sys.version_info >= (3, 10): class AsyncContextDecorator: def __call__(self, func: _AF) -> _AF: ... + + _AsyncGeneratorContextManagerBase = AsyncContextDecorator - class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], AsyncContextDecorator, Generic[_T_co]): +elif sys.version_info >= (3, 7): + _AsyncGeneratorContextManagerBase = object + +if sys.version_info >= (3, 7): + class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], _AsyncGeneratorContextManagerBase, Generic[_T_co]): # __init__ and these attributes are actually defined in the base class _GeneratorContextManagerBase, # which is more trouble than it's worth to include in the stub (see #6676) def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ... @@ -130,15 +136,6 @@ if sys.version_info >= (3, 10): self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... -elif sys.version_info >= (3, 7): - class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]): - def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ... - gen: AsyncGenerator[_T_co, Any] - func: Callable[..., AsyncGenerator[_T_co, Any]] - args: tuple[Any, ...] - kwds: dict[str, Any] - -if sys.version_info >= (3, 7): def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... class _SupportsClose(Protocol): From 89843327358fd5913ea514b19bed5c67f1d5c1ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:26:13 +0000 Subject: [PATCH 03/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/contextlib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 6ad25b468243..477e3e5144ea 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -117,7 +117,7 @@ if sys.version_info >= (3, 10): class AsyncContextDecorator: def __call__(self, func: _AF) -> _AF: ... - + _AsyncGeneratorContextManagerBase = AsyncContextDecorator elif sys.version_info >= (3, 7): From 5dc1a8efa9c8f09381ae3be06306e0e356a59555 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 5 Mar 2022 14:27:16 +0000 Subject: [PATCH 04/17] Update contextlib.pyi --- stdlib/contextlib.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 477e3e5144ea..89a50f7d625e 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -168,8 +168,8 @@ class _RedirectStream(AbstractContextManager[_T_io]): self, exctype: type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None ) -> None: ... -class redirect_stdout(_RedirectStream): ... -class redirect_stderr(_RedirectStream): ... +class redirect_stdout(_RedirectStream[_T_io]): ... +class redirect_stderr(_RedirectStream[_T_io]): ... class ExitStack(AbstractContextManager[ExitStack]): def __init__(self) -> None: ... From 53163d3a53e9fe918ed18f9c3b385b72dca4793a Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 5 Mar 2022 14:30:03 +0000 Subject: [PATCH 05/17] Update contextlib.pyi --- stdlib/contextlib.pyi | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 89a50f7d625e..c2731dea7807 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -118,13 +118,7 @@ if sys.version_info >= (3, 10): class AsyncContextDecorator: def __call__(self, func: _AF) -> _AF: ... - _AsyncGeneratorContextManagerBase = AsyncContextDecorator - -elif sys.version_info >= (3, 7): - _AsyncGeneratorContextManagerBase = object - -if sys.version_info >= (3, 7): - class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], _AsyncGeneratorContextManagerBase, Generic[_T_co]): + class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], AsyncContextDecorator, Generic[_T_co]): # __init__ and these attributes are actually defined in the base class _GeneratorContextManagerBase, # which is more trouble than it's worth to include in the stub (see #6676) def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ... @@ -136,6 +130,18 @@ if sys.version_info >= (3, 7): self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... +elif sys.version_info >= (3, 7): + class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]): + def __init__(self, func: Callable[..., AsyncIterator[_T_co]], args: tuple[Any, ...], kwds: dict[str, Any]) -> None: ... + gen: AsyncGenerator[_T_co, Any] + func: Callable[..., AsyncGenerator[_T_co, Any]] + args: tuple[Any, ...] + kwds: dict[str, Any] + async def __aexit__( + self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None + ) -> bool | None: ... + +if sys.version_info >= (3, 7): def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... class _SupportsClose(Protocol): From 17bf72d2cc2909a62ee70a6bd70c574ce6a7d47b Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:36:33 +0000 Subject: [PATCH 06/17] Update stdlib/mmap.pyi Co-authored-by: Jelle Zijlstra --- stdlib/mmap.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index e45987ca8a82..4d202acdb1e5 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -72,7 +72,7 @@ class mmap(AbstractContextManager[mmap], Iterable[int], Sized): # __len__, so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[int]: ... def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, *args: object ) -> bool | None: ... if sys.version_info >= (3, 8) and sys.platform != "win32": From 67e51a05aa4f2edfba8608da08c9e8dde47510f6 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:36:52 +0000 Subject: [PATCH 07/17] Update stdlib/multiprocessing/synchronize.pyi Co-authored-by: Jelle Zijlstra --- stdlib/multiprocessing/synchronize.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index d100a0d2d214..4ca2eae1e6af 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -30,8 +30,8 @@ class Condition(AbstractContextManager[bool]): def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ... def release(self) -> None: ... def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... + self, __exc_type: type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None + ) -> None: ... class Event: def __init__(self, lock: _LockLike | None = ..., *, ctx: BaseContext) -> None: ... From 8d181e6308471aaa78339789f465c5317b0aa8b9 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:37:07 +0000 Subject: [PATCH 08/17] Update stdlib/mmap.pyi Co-authored-by: Jelle Zijlstra --- stdlib/mmap.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index 4d202acdb1e5..c81810563146 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -73,7 +73,7 @@ class mmap(AbstractContextManager[mmap], Iterable[int], Sized): def __iter__(self) -> Iterator[int]: ... def __exit__( self, *args: object - ) -> bool | None: ... + ) -> None: ... if sys.version_info >= (3, 8) and sys.platform != "win32": MADV_NORMAL: int From 92adb46e438686876c0930a140f44212475f2a52 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:37:18 +0000 Subject: [PATCH 09/17] Update stdlib/multiprocessing/synchronize.pyi Co-authored-by: Jelle Zijlstra --- stdlib/multiprocessing/synchronize.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 4ca2eae1e6af..234b98371a26 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -54,5 +54,5 @@ class SemLock(AbstractContextManager[bool]): def acquire(self, block: bool = ..., timeout: float | None = ...) -> bool: ... def release(self) -> None: ... def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None + self, __exc_type: type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None ) -> bool | None: ... From 910f7ee9515ff84a5e4c2ef9706aec178f1c8bc5 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:37:32 +0000 Subject: [PATCH 10/17] Update stdlib/multiprocessing/synchronize.pyi Co-authored-by: Jelle Zijlstra --- stdlib/multiprocessing/synchronize.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/multiprocessing/synchronize.pyi b/stdlib/multiprocessing/synchronize.pyi index 234b98371a26..cb576abcc815 100644 --- a/stdlib/multiprocessing/synchronize.pyi +++ b/stdlib/multiprocessing/synchronize.pyi @@ -55,4 +55,4 @@ class SemLock(AbstractContextManager[bool]): def release(self) -> None: ... def __exit__( self, __exc_type: type[BaseException] | None, __exc_val: BaseException | None, __exc_tb: TracebackType | None - ) -> bool | None: ... + ) -> None: ... From 95b75bf05308a55238f10f2205a9d64814c28b3d Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:37:49 +0000 Subject: [PATCH 11/17] Update stdlib/os/__init__.pyi Co-authored-by: Jelle Zijlstra --- stdlib/os/__init__.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index f156e8ed4383..34e0d5eb29e5 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -726,8 +726,8 @@ def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... def __exit__( - self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None - ) -> bool | None: ... + self, *args: object + ) -> None: ... def close(self) -> None: ... if sys.version_info >= (3, 7): From 413929d23e3ddb6b7d757eba6ca3e9a7105cee28 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 23:38:53 +0000 Subject: [PATCH 12/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/mmap.pyi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index c81810563146..abc6ce8673ed 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -71,9 +71,7 @@ class mmap(AbstractContextManager[mmap], Iterable[int], Sized): # Doesn't actually exist, but the object is actually iterable because it has __getitem__ and # __len__, so we claim that there is also an __iter__ to help type checkers. def __iter__(self) -> Iterator[int]: ... - def __exit__( - self, *args: object - ) -> None: ... + def __exit__(self, *args: object) -> None: ... if sys.version_info >= (3, 8) and sys.platform != "win32": MADV_NORMAL: int From 12f7c45dba1b571f0faa2b8cd2eeb8717e7a6d6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 23:40:05 +0000 Subject: [PATCH 13/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/os/__init__.pyi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 34e0d5eb29e5..b465136b3a18 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -725,9 +725,7 @@ def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], AbstractContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... - def __exit__( - self, *args: object - ) -> None: ... + def __exit__(self, *args: object) -> None: ... def close(self) -> None: ... if sys.version_info >= (3, 7): From cf1447bd1c43680d58f3be2a4a8456f0eefee332 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:41:53 +0000 Subject: [PATCH 14/17] Improve `_AsyncGeneratorContextManager.__aexit__` --- stdlib/contextlib.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index c2731dea7807..c050dc13be62 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -128,7 +128,7 @@ if sys.version_info >= (3, 10): kwds: dict[str, Any] async def __aexit__( self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... + ) -> bool: ... elif sys.version_info >= (3, 7): class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]): @@ -139,7 +139,7 @@ elif sys.version_info >= (3, 7): kwds: dict[str, Any] async def __aexit__( self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool | None: ... + ) -> bool: ... if sys.version_info >= (3, 7): def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ... From 8825f97cc9a42031450bf0409c9475a7ec68df00 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:46:18 +0000 Subject: [PATCH 15/17] Update mmap.pyi --- stdlib/mmap.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/mmap.pyi b/stdlib/mmap.pyi index abc6ce8673ed..c057ab2f1b2b 100644 --- a/stdlib/mmap.pyi +++ b/stdlib/mmap.pyi @@ -1,7 +1,6 @@ import sys from _typeshed import ReadableBuffer from contextlib import AbstractContextManager -from types import TracebackType from typing import Iterable, Iterator, NoReturn, Sized, overload ACCESS_DEFAULT: int From 247fedb8b3f937401b7725c1bbd6b063bf9822e7 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 6 Mar 2022 23:46:38 +0000 Subject: [PATCH 16/17] Update __init__.pyi --- stdlib/os/__init__.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index b465136b3a18..f59b2de7bc23 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -17,7 +17,6 @@ from builtins import OSError from contextlib import AbstractContextManager from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper as _TextIOWrapper from subprocess import Popen -from types import TracebackType from typing import ( IO, Any, From ee35c1892058238cfab19aab9f217f4608a4e572 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 7 Mar 2022 00:04:42 +0000 Subject: [PATCH 17/17] Revert! Revert! --- stdlib/contextlib.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index c050dc13be62..c2731dea7807 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -128,7 +128,7 @@ if sys.version_info >= (3, 10): kwds: dict[str, Any] async def __aexit__( self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool: ... + ) -> bool | None: ... elif sys.version_info >= (3, 7): class _AsyncGeneratorContextManager(AbstractAsyncContextManager[_T_co], Generic[_T_co]): @@ -139,7 +139,7 @@ elif sys.version_info >= (3, 7): kwds: dict[str, Any] async def __aexit__( self, typ: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None - ) -> bool: ... + ) -> bool | None: ... if sys.version_info >= (3, 7): def asynccontextmanager(func: Callable[_P, AsyncIterator[_T_co]]) -> Callable[_P, _AsyncGeneratorContextManager[_T_co]]: ...