From 21e174a192f2fdf9902feeb8c3fb696ded930a48 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sun, 2 May 2021 06:21:03 -0700 Subject: [PATCH] inspect: update for py310 (#5296) --- stdlib/inspect.pyi | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/stdlib/inspect.pyi b/stdlib/inspect.pyi index d0627d549..cb521b4e5 100644 --- a/stdlib/inspect.pyi +++ b/stdlib/inspect.pyi @@ -105,7 +105,18 @@ def indentsize(line: str) -> int: ... # # Introspecting callables with the Signature object # -def signature(obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ... +if sys.version_info >= (3, 10): + def signature( + obj: Callable[..., Any], + *, + follow_wrapped: bool = ..., + globals: Optional[Mapping[str, Any]] = ..., + locals: Optional[Mapping[str, Any]] = ..., + eval_str: bool = ..., + ) -> Signature: ... + +else: + def signature(obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ... class Signature: def __init__(self, parameters: Optional[Sequence[Parameter]] = ..., *, return_annotation: Any = ...) -> None: ... @@ -119,8 +130,29 @@ class Signature: def bind(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def bind_partial(self, *args: Any, **kwargs: Any) -> BoundArguments: ... def replace(self, *, parameters: Optional[Sequence[Parameter]] = ..., return_annotation: Any = ...) -> Signature: ... - @classmethod - def from_callable(cls, obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ... + if sys.version_info >= (3, 10): + @classmethod + def from_callable( + cls, + obj: Callable[..., Any], + *, + follow_wrapped: bool = ..., + globals: Optional[Mapping[str, Any]] = ..., + locals: Optional[Mapping[str, Any]] = ..., + eval_str: bool = ..., + ) -> Signature: ... + else: + @classmethod + def from_callable(cls, obj: Callable[..., Any], *, follow_wrapped: bool = ...) -> Signature: ... + +if sys.version_info >= (3, 10): + def get_annotations( + obj: Union[Callable[..., Any], Type[Any], ModuleType], + *, + globals: Optional[Mapping[str, Any]] = ..., + locals: Optional[Mapping[str, Any]] = ..., + eval_str: bool = ..., + ) -> Dict[str, Any]: ... # The name is the same as the enum's name in CPython class _ParameterKind(enum.IntEnum):