From 4ae6d38f9694f02fbbf0ad5d4bff274e32b47eeb Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 30 Aug 2023 17:50:11 +0100 Subject: [PATCH] Use latest Python for stubtest in CI (#10641) --- .github/workflows/daily.yml | 1 + .github/workflows/stubtest_stdlib.yml | 1 + stdlib/enum.pyi | 6 +++--- stdlib/os/__init__.pyi | 7 ++++++- stdlib/pydoc.pyi | 4 ++-- stdlib/ssl.pyi | 10 ++++++---- tests/stubtest_allowlists/darwin-py312.txt | 3 +++ tests/stubtest_allowlists/linux-py312.txt | 3 +++ tests/stubtest_allowlists/py310.txt | 2 ++ tests/stubtest_allowlists/py312.txt | 4 ++++ tests/stubtest_allowlists/py38.txt | 2 ++ tests/stubtest_allowlists/py39.txt | 2 ++ tests/stubtest_allowlists/py3_common.txt | 2 -- 13 files changed, 35 insertions(+), 12 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 6a40d3400..145290416 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -48,6 +48,7 @@ jobs: cache: pip cache-dependency-path: requirements-tests.txt allow-prereleases: true + check-latest: true - name: Install dependencies run: pip install -r requirements-tests.txt - name: Run stubtest diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index ae38dccca..ad308918e 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -44,6 +44,7 @@ jobs: cache: pip cache-dependency-path: requirements-tests.txt allow-prereleases: true + check-latest: true - name: Install dependencies run: pip install -r requirements-tests.txt - name: Run stubtest diff --git a/stdlib/enum.pyi b/stdlib/enum.pyi index a8ba7bf15..e6eaf6c41 100644 --- a/stdlib/enum.pyi +++ b/stdlib/enum.pyi @@ -33,7 +33,7 @@ if sys.version_info >= (3, 11): "verify", ] -if sys.version_info >= (3, 12): +if sys.version_info >= (3, 11): __all__ += ["pickle_by_enum_name", "pickle_by_global_name"] _EnumMemberT = TypeVar("_EnumMemberT") @@ -188,7 +188,7 @@ class Enum(metaclass=EnumMeta): def __hash__(self) -> int: ... def __format__(self, format_spec: str) -> str: ... def __reduce_ex__(self, proto: Unused) -> tuple[Any, ...]: ... - if sys.version_info >= (3, 12): + if sys.version_info >= (3, 11): def __copy__(self) -> Self: ... def __deepcopy__(self, memo: Any) -> Self: ... @@ -294,6 +294,6 @@ class auto(IntFlag): def value(self) -> Any: ... def __new__(cls) -> Self: ... -if sys.version_info >= (3, 12): +if sys.version_info >= (3, 11): def pickle_by_global_name(self: Enum, proto: int) -> str: ... def pickle_by_enum_name(self: _EnumMemberT, proto: int) -> tuple[Callable[..., Any], tuple[type[_EnumMemberT], str]]: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index 994595aae..f10179845 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -602,7 +602,12 @@ def isatty(__fd: int) -> bool: ... if sys.platform != "win32" and sys.version_info >= (3, 11): def login_tty(__fd: int) -> None: ... -def lseek(__fd: int, __position: int, __how: int) -> int: ... +if sys.version_info >= (3, 11): + def lseek(__fd: int, __position: int, __whence: int) -> int: ... + +else: + def lseek(__fd: int, __position: int, __how: int) -> int: ... + def open(path: StrOrBytesPath, flags: int, mode: int = 0o777, *, dir_fd: int | None = None) -> int: ... def pipe() -> tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... diff --git a/stdlib/pydoc.pyi b/stdlib/pydoc.pyi index 7791c977a..1b09bcb05 100644 --- a/stdlib/pydoc.pyi +++ b/stdlib/pydoc.pyi @@ -198,7 +198,7 @@ def render_doc( thing: str | object, title: str = "Python Library Documentation: %s", forceload: bool = ..., renderer: Doc | None = None ) -> str: ... -if sys.version_info >= (3, 12): +if sys.version_info >= (3, 11): def doc( thing: str | object, title: str = "Python Library Documentation: %s", @@ -230,7 +230,7 @@ class Helper: def __call__(self, request: str | Helper | object = ...) -> None: ... def interact(self) -> None: ... def getline(self, prompt: str) -> str: ... - if sys.version_info >= (3, 12): + if sys.version_info >= (3, 11): def help(self, request: Any, is_cli: bool = False) -> None: ... else: def help(self, request: Any) -> None: ... diff --git a/stdlib/ssl.pyi b/stdlib/ssl.pyi index 1c49b130e..73762cd75 100644 --- a/stdlib/ssl.pyi +++ b/stdlib/ssl.pyi @@ -201,12 +201,13 @@ class Options(enum.IntFlag): OP_NO_RENEGOTIATION: int if sys.version_info >= (3, 8): OP_ENABLE_MIDDLEBOX_COMPAT: int - if sys.platform == "linux": - OP_IGNORE_UNEXPECTED_EOF: int if sys.version_info >= (3, 12): OP_LEGACY_SERVER_CONNECT: int if sys.version_info >= (3, 12) and sys.platform != "linux": OP_ENABLE_KTLS: int + if sys.version_info >= (3, 11): + OP_IGNORE_UNEXPECTED_EOF: int + elif sys.version_info >= (3, 8) and sys.platform == "linux": OP_IGNORE_UNEXPECTED_EOF: int OP_ALL: Options @@ -224,12 +225,13 @@ OP_NO_TICKET: Options OP_NO_RENEGOTIATION: Options if sys.version_info >= (3, 8): OP_ENABLE_MIDDLEBOX_COMPAT: Options - if sys.platform == "linux": - OP_IGNORE_UNEXPECTED_EOF: Options if sys.version_info >= (3, 12): OP_LEGACY_SERVER_CONNECT: Options if sys.version_info >= (3, 12) and sys.platform != "linux": OP_ENABLE_KTLS: Options +if sys.version_info >= (3, 11): + OP_IGNORE_UNEXPECTED_EOF: Options +elif sys.version_info >= (3, 8) and sys.platform == "linux": OP_IGNORE_UNEXPECTED_EOF: Options HAS_NEVER_CHECK_COMMON_NAME: bool diff --git a/tests/stubtest_allowlists/darwin-py312.txt b/tests/stubtest_allowlists/darwin-py312.txt index b9e9f0e2c..a2ca63a76 100644 --- a/tests/stubtest_allowlists/darwin-py312.txt +++ b/tests/stubtest_allowlists/darwin-py312.txt @@ -28,3 +28,6 @@ xxlimited.Xxo.x_exports (locale.dgettext)? (locale.gettext)? (locale.textdomain)? + +# should be removable once 3.12.0rc2 is released: +posix.lseek diff --git a/tests/stubtest_allowlists/linux-py312.txt b/tests/stubtest_allowlists/linux-py312.txt index 22a7c72d6..ce665e576 100644 --- a/tests/stubtest_allowlists/linux-py312.txt +++ b/tests/stubtest_allowlists/linux-py312.txt @@ -44,3 +44,6 @@ tty.__all__ tty.cfmakecbreak tty.cfmakeraw xxlimited.Xxo.x_exports + +# should be removable once 3.12.0rc2 is released: +posix.lseek diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 5fcdf0f1b..6dd6ef21f 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -160,3 +160,5 @@ asynchat.async_chat.use_encoding asynchat.find_prefix_at_end pkgutil.ImpImporter\..* pkgutil.ImpLoader\..* + +types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index 961a06b97..0a7bec9d1 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -173,3 +173,7 @@ typing\._SpecialForm.* typing\.NamedTuple typing\.LiteralString typing\.Annotated + +# These two should be removable after 3.12rc2 is released: +types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime +os.lseek # a pos-only parameter name changed in py311/py312 diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index 1662f25db..de2c1a9e1 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -158,3 +158,5 @@ asynchat.async_chat.use_encoding asynchat.find_prefix_at_end pkgutil.ImpImporter\..* pkgutil.ImpLoader\..* + +types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index 85dc5b7bf..aaa75a0c1 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -149,3 +149,5 @@ asynchat.async_chat.use_encoding asynchat.find_prefix_at_end pkgutil.ImpImporter\..* pkgutil.ImpLoader\..* + +types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index a0f3d786c..c312cd2ca 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -659,5 +659,3 @@ typing(_extensions)?\.IO\.__iter__ # See https://github.com/python/typeshed/com # Omit internal _KEEP argument tarfile.TarInfo.replace - -types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime