From 7e2174e9170cb3e78ee8c59c8a0532a7f79c54ef Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 3 Feb 2022 17:10:18 +0000 Subject: [PATCH 1/5] correct asyncio.locks._ContextManagerMixin and _ContextManager types --- stdlib/asyncio/locks.pyi | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index ec959e89ba25..a74947fc06c1 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,7 +1,7 @@ import sys from collections import deque from types import TracebackType -from typing import Any, Callable, Generator, TypeVar +from typing import Any, Callable, Generator, TypeVar, NoReturn from .events import AbstractEventLoop from .futures import Future @@ -10,7 +10,6 @@ _T = TypeVar("_T") if sys.version_info >= (3, 9): class _ContextManagerMixin: - def __init__(self, lock: Lock | Semaphore) -> None: ... async def __aenter__(self) -> None: ... async def __aexit__( self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None @@ -19,13 +18,12 @@ if sys.version_info >= (3, 9): else: class _ContextManager: def __init__(self, lock: Lock | Semaphore) -> None: ... - def __enter__(self) -> object: ... + def __enter__(self) -> None: ... def __exit__(self, *args: Any) -> None: ... class _ContextManagerMixin: - def __init__(self, lock: Lock | Semaphore) -> None: ... # Apparently this exists to *prohibit* use as a context manager. - def __enter__(self) -> object: ... + def __enter__(self) -> NoReturn: ... def __exit__(self, *args: Any) -> None: ... def __iter__(self) -> Generator[Any, None, _ContextManager]: ... def __await__(self) -> Generator[Any, None, _ContextManager]: ... From 0409eb5ce8e4141812363030b38c623ce1c90d90 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 3 Feb 2022 17:11:33 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/asyncio/locks.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index a74947fc06c1..5cfd9013a1ae 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,7 +1,7 @@ import sys from collections import deque from types import TracebackType -from typing import Any, Callable, Generator, TypeVar, NoReturn +from typing import Any, Callable, Generator, NoReturn, TypeVar from .events import AbstractEventLoop from .futures import Future From 5b0d390b073055c6c5ad2168b1004d41ea804922 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 09:21:27 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/asyncio/locks.pyi | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 710e8845869b..1db15a80a042 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,13 +1,9 @@ import sys from collections import deque from types import TracebackType - from typing import Any, Callable, Generator, NoReturn, TypeVar - -from typing import Any, Callable, Generator, TypeVar from typing_extensions import Literal - from .events import AbstractEventLoop from .futures import Future From 9017e6bf9ba61dcbb66e249d7c02bb690d21551b Mon Sep 17 00:00:00 2001 From: Akuli Date: Fri, 4 Feb 2022 15:41:51 +0200 Subject: [PATCH 4/5] Update stdlib/asyncio/locks.pyi Co-authored-by: Thomas Grainger --- stdlib/asyncio/locks.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index 1db15a80a042..f7ba1423b3f4 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -24,8 +24,8 @@ else: class _ContextManagerMixin: # Apparently this exists to *prohibit* use as a context manager. - def __enter__(self) -> NoReturn: ... - def __exit__(self, *args: Any) -> None: ... + # def __enter__(self) -> NoReturn: ... see: https://github.com/python/typing/issues/1043 + # def __exit__(self, *args: Any) -> None: ... def __iter__(self) -> Generator[Any, None, _ContextManager]: ... def __await__(self) -> Generator[Any, None, _ContextManager]: ... async def __aenter__(self) -> None: ... From 4b1d6a341a0e11fdcdd1efe898ff3c2dcf5a258c Mon Sep 17 00:00:00 2001 From: Akuli Date: Fri, 4 Feb 2022 15:48:39 +0200 Subject: [PATCH 5/5] Update stdlib/asyncio/locks.pyi Co-authored-by: Alex Waygood --- stdlib/asyncio/locks.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/asyncio/locks.pyi b/stdlib/asyncio/locks.pyi index f7ba1423b3f4..3fe9a5b72d00 100644 --- a/stdlib/asyncio/locks.pyi +++ b/stdlib/asyncio/locks.pyi @@ -1,7 +1,7 @@ import sys from collections import deque from types import TracebackType -from typing import Any, Callable, Generator, NoReturn, TypeVar +from typing import Any, Callable, Generator, TypeVar from typing_extensions import Literal from .events import AbstractEventLoop