From 4cdcb955fcc4f23d84e6923a24c9403323a98802 Mon Sep 17 00:00:00 2001 From: Jia Chen Date: Thu, 20 Feb 2025 15:15:20 -0800 Subject: [PATCH 1/3] Make `Any` a proper class instead of an alias to `object()` --- stdlib/typing.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 7c1b171a730b..c33b67429917 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -130,7 +130,8 @@ if sys.version_info >= (3, 12): if sys.version_info >= (3, 13): __all__ += ["get_protocol_members", "is_protocol", "NoDefault", "TypeIs", "ReadOnly"] -Any = object() +class Any: + pass class _Final: ... From 2f8ed8ee9a8b2d84869e61a2bf9083d5ffbb976a Mon Sep 17 00:00:00 2001 From: Jia Chen Date: Fri, 28 Feb 2025 13:16:50 -0800 Subject: [PATCH 2/3] Add Any exclusion to stubtest --- stdlib/@tests/stubtest_allowlists/common.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index f5d74200e417..ce4847d2f387 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -463,6 +463,7 @@ types.GenericAlias.__getattr__ typing.type_check_only # typing decorator that is not available at runtime # Details of runtime definition don't need to be in stubs +typing\.Any typing._Final typing._Final.__init_subclass__ typing\.Protocol From 5d0b0fb5da2e8e2e9bdf8de276900ac59afa7018 Mon Sep 17 00:00:00 2001 From: Jia Chen Date: Tue, 18 Mar 2025 14:32:21 -0700 Subject: [PATCH 3/3] Fix formatting and ignore and more ignores on Any* in stub tests --- stdlib/@tests/stubtest_allowlists/common.txt | 2 +- stdlib/typing.pyi | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 8ba232359bd3..1c0e13b49884 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -460,11 +460,11 @@ types.GenericAlias.__getattr__ typing.type_check_only # typing decorator that is not available at runtime # Details of runtime definition don't need to be in stubs -typing\.Any typing._Final typing._Final.__init_subclass__ typing\.Protocol typing(_extensions)?\._TypedDict +typing(_extensions)?\.Any.* typing(_extensions)?\.Generic typing(_extensions)?\.TypedDict typing_extensions\.ParamSpec.* diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index 1f6c337d1baf..1ab5dae09cb4 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -130,9 +130,7 @@ if sys.version_info >= (3, 12): if sys.version_info >= (3, 13): __all__ += ["get_protocol_members", "is_protocol", "NoDefault", "TypeIs", "ReadOnly"] -class Any: - pass - +class Any: ... class _Final: ... def final(f: _T) -> _T: ...