From cd93803b607183fc38eb77c65e2bc49108e87c80 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sun, 17 May 2026 11:13:27 +0800 Subject: [PATCH 1/2] Narrow ProfileFunction and TraceFunction --- stdlib/_typeshed/__init__.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index c96f212b42e9..e7e04663c8a2 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -350,10 +350,10 @@ AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001 # Objects suitable to be passed to sys.setprofile, threading.setprofile, and similar -ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object] +ProfileFunction: TypeAlias = Callable[[FrameType, Literal["call", "return", "c_call", "c_return", "c_exception"], Any], object] # Objects suitable to be passed to sys.settrace, threading.settrace, and similar -TraceFunction: TypeAlias = Callable[[FrameType, str, Any], TraceFunction | None] +TraceFunction: TypeAlias = Callable[[FrameType, Literal["call", "line", "return", "exception", "opcode"], Any], TraceFunction | None] # experimental # Might not work as expected for pyright, see From 403edcb147b9826c5fb080b511caf67ef92bc751 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 03:17:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/_typeshed/__init__.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index e7e04663c8a2..0516b59ea7b1 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -353,7 +353,9 @@ StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001 ProfileFunction: TypeAlias = Callable[[FrameType, Literal["call", "return", "c_call", "c_return", "c_exception"], Any], object] # Objects suitable to be passed to sys.settrace, threading.settrace, and similar -TraceFunction: TypeAlias = Callable[[FrameType, Literal["call", "line", "return", "exception", "opcode"], Any], TraceFunction | None] +TraceFunction: TypeAlias = Callable[ + [FrameType, Literal["call", "line", "return", "exception", "opcode"], Any], TraceFunction | None +] # experimental # Might not work as expected for pyright, see