From a9edc2668db2b96d3535d7372c219a1e0a27514a Mon Sep 17 00:00:00 2001 From: Sumit Date: Wed, 11 Nov 2026 19:59:31 +0530 Subject: [PATCH 1/2] [types] Add `__signature__` to `FunctionType` --- stdlib/types.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 39aaa7e9685f..5c8facb88806 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -17,6 +17,7 @@ from collections.abc import ( ValuesView, ) from importlib.machinery import ModuleSpec +from inspect import Signature from typing import Any, ClassVar, Literal, ParamSpec, TypeVar, final, overload from typing_extensions import Self, TypeAliasType, TypeVarTuple, deprecated, disjoint_base @@ -95,6 +96,7 @@ class FunctionType: __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __module__: str + __signature__: Signature | None if sys.version_info >= (3, 13): def __new__( cls, From 591b3824f358272cd75352609023f48031c614eb Mon Sep 17 00:00:00 2001 From: Sumit Date: Wed, 11 Nov 2026 20:32:37 +0530 Subject: [PATCH 2/2] Avoid inspect import cycle for FunctionType.__signature__ --- stdlib/types.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 5c8facb88806..9532577d9e68 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -17,7 +17,6 @@ from collections.abc import ( ValuesView, ) from importlib.machinery import ModuleSpec -from inspect import Signature from typing import Any, ClassVar, Literal, ParamSpec, TypeVar, final, overload from typing_extensions import Self, TypeAliasType, TypeVarTuple, deprecated, disjoint_base @@ -96,7 +95,7 @@ class FunctionType: __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] __module__: str - __signature__: Signature | None + __signature__: Any | None # inspect.Signature | None (cannot import inspect due to import cycle) if sys.version_info >= (3, 13): def __new__( cls,