From 33be43bbe047c7f4c0861dab7d44360dcd9fb049 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 23 Oct 2021 10:17:44 +0100 Subject: [PATCH 1/7] add contextlib.chdir --- stdlib/contextlib.pyi | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 8c362cfd1633..a73e93669600 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import Self +from _typeshed import Self, StrOrBytesPath from types import TracebackType from typing import ( IO, @@ -124,3 +124,13 @@ elif sys.version_info >= (3, 7): def __init__(self: nullcontext[_T], enter_result: _T) -> None: ... def __enter__(self) -> _T: ... def __exit__(self, *exctype: Any) -> None: ... + +if sys.version_info >= (3, 11): + _FdOrAnyPath = int | StrOrBytesPath + _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=_FdOrAnyPath) + class chdir(AbstractContextManager[_T_fd_or_any_path]): + path: _T_fd_or_any_path + _old_cwd: list[str] + def __init__(self, path: _FdOrAnyPath) -> None: ... + def __enter__(self) -> None: ... + def __exit__(self, *excinfo: Any) -> None: ... From ea866c2bc20f8cdf4c03499496bc4f97c8c2977e Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 23 Oct 2021 10:24:49 +0100 Subject: [PATCH 2/7] Update stdlib/contextlib.pyi Co-authored-by: Akuli --- stdlib/contextlib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index a73e93669600..ea8390c3353b 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -131,6 +131,6 @@ if sys.version_info >= (3, 11): class chdir(AbstractContextManager[_T_fd_or_any_path]): path: _T_fd_or_any_path _old_cwd: list[str] - def __init__(self, path: _FdOrAnyPath) -> None: ... + def __init__(self, path: _T_fd_or_any_path) -> None: ... def __enter__(self) -> None: ... def __exit__(self, *excinfo: Any) -> None: ... From 2cbe6ecb1dbc3a3e81c8120714d779a0f0e1122b Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 23 Oct 2021 10:32:30 +0100 Subject: [PATCH 3/7] Update stdlib/contextlib.pyi Co-authored-by: Akuli --- stdlib/contextlib.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index ea8390c3353b..fffb7c24c749 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -126,8 +126,7 @@ elif sys.version_info >= (3, 7): def __exit__(self, *exctype: Any) -> None: ... if sys.version_info >= (3, 11): - _FdOrAnyPath = int | StrOrBytesPath - _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=_FdOrAnyPath) + _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=int | StrOrBytesPath) class chdir(AbstractContextManager[_T_fd_or_any_path]): path: _T_fd_or_any_path _old_cwd: list[str] From 5f103bdf311e258f8527aa1ee058070dcb127fd1 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 23 Oct 2021 21:05:51 +0100 Subject: [PATCH 4/7] Update stdlib/contextlib.pyi Co-authored-by: Jelle Zijlstra --- stdlib/contextlib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index fffb7c24c749..17c078162893 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -132,4 +132,4 @@ if sys.version_info >= (3, 11): _old_cwd: list[str] def __init__(self, path: _T_fd_or_any_path) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, *excinfo: Any) -> None: ... + def __exit__(self, *excinfo: object) -> None: ... From db369513095dcfb6709386d1d86237a3cd590665 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 24 Oct 2021 14:05:23 +0100 Subject: [PATCH 5/7] Update stdlib/contextlib.pyi --- stdlib/contextlib.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 17c078162893..19cfa224f6db 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -127,7 +127,7 @@ elif sys.version_info >= (3, 7): if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=int | StrOrBytesPath) - class chdir(AbstractContextManager[_T_fd_or_any_path]): + class chdir(AbstractContextManager[None], Generic[_T_fd_or_any_path]): path: _T_fd_or_any_path _old_cwd: list[str] def __init__(self, path: _T_fd_or_any_path) -> None: ... From 34a9d88d7e9287a8f788eea3e511943139fad5e0 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 24 Oct 2021 15:23:58 +0100 Subject: [PATCH 6/7] import generic --- stdlib/contextlib.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 19cfa224f6db..44f8d26d8e24 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -9,6 +9,7 @@ from typing import ( Awaitable, Callable, ContextManager, + Generic, Iterator, Optional, Type, From 93faac1dc43394cdc5c15f45ab138921aa1e156c Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 8 Nov 2021 19:43:21 +0000 Subject: [PATCH 7/7] remove contextlib:chdir._old_cwd --- stdlib/contextlib.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/contextlib.pyi b/stdlib/contextlib.pyi index 44f8d26d8e24..f0ae8312b6bc 100644 --- a/stdlib/contextlib.pyi +++ b/stdlib/contextlib.pyi @@ -130,7 +130,6 @@ if sys.version_info >= (3, 11): _T_fd_or_any_path = TypeVar("_T_fd_or_any_path", bound=int | StrOrBytesPath) class chdir(AbstractContextManager[None], Generic[_T_fd_or_any_path]): path: _T_fd_or_any_path - _old_cwd: list[str] def __init__(self, path: _T_fd_or_any_path) -> None: ... def __enter__(self) -> None: ... def __exit__(self, *excinfo: object) -> None: ...