From 89d7acabbfc7bcb28ea5ce1a2f42893bd31cd58d Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 27 Jun 2026 15:39:08 +0800 Subject: [PATCH 1/6] commit --- stdlib/builtins.pyi | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 9c8394ced492..fcd8378b9ab9 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1882,7 +1882,35 @@ def iter(object: Callable[[], _T], sentinel: object, /) -> Iterator[_T]: ... _ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] +@overload +def isinstance(obj: object, class_or_tuple: type[_T] | tuple[type[_T]], /) -> TypeIs[_T]: ... +@overload +def isinstance( + obj: object, class_or_tuple: tuple[type[_T], type[_T1]], / +) -> TypeIs[_T | _T1]: ... +@overload +def isinstance( + obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[T2]], / +) -> TypeIs[T | T1 | T2]: ... +@overload +def isinstance( + obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3]], / +) -> TypeIs[_T | _T1 | _T2 | _T3]: ... +@overload +def isinstance( + obj: object, + class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3], type[_T4]], + /, +) -> TypeIs[_T | _T1 | _T2 | _T3 | _T4]: ... +@overload +def isinstance( + obj: object, + class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3], type[_T4], type[_T5]], + /, +) -> TypeIs[_T | _T1 | _T2 | _T3 | _T4 | _T5]: ... +@overload def isinstance(obj: object, class_or_tuple: _ClassInfo, /) -> bool: ... + def issubclass(cls: type, class_or_tuple: _ClassInfo, /) -> bool: ... def len(obj: Sized, /) -> int: ... From 2007e47c0fd9afd2f91b74b59515650f57727328 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 27 Jun 2026 15:42:22 +0800 Subject: [PATCH 2/6] hotfix --- stdlib/builtins.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index fcd8378b9ab9..fea470de6e4f 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1890,8 +1890,8 @@ def isinstance( ) -> TypeIs[_T | _T1]: ... @overload def isinstance( - obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[T2]], / -) -> TypeIs[T | T1 | T2]: ... + obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2]], / +) -> TypeIs[_T | _T1 | _T2]: ... @overload def isinstance( obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3]], / From ad623ad17532a5ed7d17d29efa749b8510d71d11 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 27 Jun 2026 07:44:52 +0000 Subject: [PATCH 3/6] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/builtins.pyi | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index fea470de6e4f..2db9868662d1 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1885,28 +1885,20 @@ _ClassInfo: TypeAlias = type | types.UnionType | tuple[_ClassInfo, ...] @overload def isinstance(obj: object, class_or_tuple: type[_T] | tuple[type[_T]], /) -> TypeIs[_T]: ... @overload -def isinstance( - obj: object, class_or_tuple: tuple[type[_T], type[_T1]], / -) -> TypeIs[_T | _T1]: ... +def isinstance(obj: object, class_or_tuple: tuple[type[_T], type[_T1]], /) -> TypeIs[_T | _T1]: ... @overload -def isinstance( - obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2]], / -) -> TypeIs[_T | _T1 | _T2]: ... +def isinstance(obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2]], /) -> TypeIs[_T | _T1 | _T2]: ... @overload def isinstance( obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3]], / ) -> TypeIs[_T | _T1 | _T2 | _T3]: ... @overload def isinstance( - obj: object, - class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3], type[_T4]], - /, + obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3], type[_T4]], / ) -> TypeIs[_T | _T1 | _T2 | _T3 | _T4]: ... @overload def isinstance( - obj: object, - class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3], type[_T4], type[_T5]], - /, + obj: object, class_or_tuple: tuple[type[_T], type[_T1], type[_T2], type[_T3], type[_T4], type[_T5]], / ) -> TypeIs[_T | _T1 | _T2 | _T3 | _T4 | _T5]: ... @overload def isinstance(obj: object, class_or_tuple: _ClassInfo, /) -> bool: ... From 9e44809a0bdd18972eb513d539c59e69347e6488 Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 10 Oct 2026 22:35:09 +0800 Subject: [PATCH 4/6] try to add tests --- stdlib/@tests/test_cases/builtins/check_isinstance.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 stdlib/@tests/test_cases/builtins/check_isinstance.py diff --git a/stdlib/@tests/test_cases/builtins/check_isinstance.py b/stdlib/@tests/test_cases/builtins/check_isinstance.py new file mode 100644 index 000000000000..fc2c28995d05 --- /dev/null +++ b/stdlib/@tests/test_cases/builtins/check_isinstance.py @@ -0,0 +1,8 @@ +from typing import Any, cast +from typing_extensions import TypeIs, assert_type +o = cast(Any, '') +assert_type(isinstance(o, int), TypeIs[int]) +assert_type(isinstance(o, object), TypeIs[object]) +assert_type(isinstance(o, str), TypeIs[str]) +assert_type(isinstance(o, (bytes, memoryview[int])), TypeIs[bytes | memoryview[int]]) +assert_type(isinstance(o, (set, dict)), TypeIs[set[Any] | dict[Any, Any]]) From c8d3dbafe2a3cdbb3119810b2235f844887100c9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 10 Oct 2026 14:37:12 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/@tests/test_cases/builtins/check_isinstance.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/@tests/test_cases/builtins/check_isinstance.py b/stdlib/@tests/test_cases/builtins/check_isinstance.py index fc2c28995d05..f7f55c13fae8 100644 --- a/stdlib/@tests/test_cases/builtins/check_isinstance.py +++ b/stdlib/@tests/test_cases/builtins/check_isinstance.py @@ -1,6 +1,7 @@ from typing import Any, cast from typing_extensions import TypeIs, assert_type -o = cast(Any, '') + +o = cast(Any, "") assert_type(isinstance(o, int), TypeIs[int]) assert_type(isinstance(o, object), TypeIs[object]) assert_type(isinstance(o, str), TypeIs[str]) From 748f3b1329ca3e2cdae603d992b19dcd0cdd435f Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sun, 11 Oct 2026 10:54:19 +0800 Subject: [PATCH 6/6] commit --- stdlib/@tests/test_cases/builtins/check_isinstance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/@tests/test_cases/builtins/check_isinstance.py b/stdlib/@tests/test_cases/builtins/check_isinstance.py index f7f55c13fae8..67def3187d89 100644 --- a/stdlib/@tests/test_cases/builtins/check_isinstance.py +++ b/stdlib/@tests/test_cases/builtins/check_isinstance.py @@ -5,5 +5,5 @@ assert_type(isinstance(o, int), TypeIs[int]) assert_type(isinstance(o, object), TypeIs[object]) assert_type(isinstance(o, str), TypeIs[str]) -assert_type(isinstance(o, (bytes, memoryview[int])), TypeIs[bytes | memoryview[int]]) -assert_type(isinstance(o, (set, dict)), TypeIs[set[Any] | dict[Any, Any]]) +assert_type(isinstance(o, (bytes, memoryview)), TypeIs[bytes | memoryview[int]]) +assert_type(isinstance(o, (set, type[dict])), TypeIs[set[Any] | type[dict[Any, Any]]])