From a046615d01f5c487837b4ddfae6e1a3d2fbae6e0 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Wed, 24 May 2023 23:55:24 -0700 Subject: [PATCH 1/2] builtins: updates for py312 --- stdlib/builtins.pyi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 6bc9c7ec8b3a..dd87622aca4c 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -188,6 +188,8 @@ class type: if sys.version_info >= (3, 10): def __or__(self, __value: Any) -> types.UnionType: ... def __ror__(self, __value: Any) -> types.UnionType: ... + if sys.version_info >= (3, 12): + __type_params__: tuple[object, ...] class super: @overload @@ -245,6 +247,9 @@ class int: signed: bool = False, ) -> Self: ... + if sys.version_info >= (3, 12): + def is_integer(self) -> Literal[True]: ... + def __add__(self, __value: int) -> int: ... def __sub__(self, __value: int) -> int: ... def __mul__(self, __value: int) -> int: ... @@ -1912,6 +1917,8 @@ class ImportError(Exception): name: str | None path: str | None msg: str # undocumented + if sys.version_info >= (3, 12): + name_from: str | None # undocumented class LookupError(Exception): ... class MemoryError(Exception): ... From 4323e937ddba30aeccb4c709cbf0a25b4c6b4988 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Fri, 2 Jun 2023 13:27:31 +0100 Subject: [PATCH 2/2] Add it to function classes as well --- stdlib/builtins.pyi | 17 +++++++++++++++-- stdlib/types.pyi | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index dd87622aca4c..4297b49c2780 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -54,7 +54,18 @@ from typing import ( # noqa: Y022 overload, type_check_only, ) -from typing_extensions import Concatenate, Literal, LiteralString, ParamSpec, Self, SupportsIndex, TypeAlias, TypeGuard, final +from typing_extensions import ( + Concatenate, + Literal, + LiteralString, + ParamSpec, + Self, + SupportsIndex, + TypeAlias, + TypeGuard, + TypeVarTuple, + final, +) if sys.version_info >= (3, 9): from types import GenericAlias @@ -189,7 +200,7 @@ class type: def __or__(self, __value: Any) -> types.UnionType: ... def __ror__(self, __value: Any) -> types.UnionType: ... if sys.version_info >= (3, 12): - __type_params__: tuple[object, ...] + __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] class super: @overload @@ -965,6 +976,8 @@ class function: if sys.version_info >= (3, 10): @property def __builtins__(self) -> dict[str, Any]: ... + if sys.version_info >= (3, 12): + __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __module__: str # mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any. diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 43475d91279d..fb31fbda6b38 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -17,7 +17,7 @@ from importlib.machinery import ModuleSpec # pytype crashes if types.MappingProxyType inherits from collections.abc.Mapping instead of typing.Mapping from typing import Any, ClassVar, Generic, Mapping, Protocol, TypeVar, overload # noqa: Y022 -from typing_extensions import Literal, ParamSpec, final +from typing_extensions import Literal, ParamSpec, TypeVarTuple, final __all__ = [ "FunctionType", @@ -94,6 +94,8 @@ class FunctionType: if sys.version_info >= (3, 10): @property def __builtins__(self) -> dict[str, Any]: ... + if sys.version_info >= (3, 12): + __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __module__: str def __init__(