diff --git a/stdlib/@tests/test_cases/builtins/check_type.py b/stdlib/@tests/test_cases/builtins/check_type.py index 1eafcf482fb6..e29550169d99 100644 --- a/stdlib/@tests/test_cases/builtins/check_type.py +++ b/stdlib/@tests/test_cases/builtins/check_type.py @@ -1,4 +1,12 @@ +from typing_extensions import assert_type + + class Meta(type): ... call = Meta.__dict__["__call__"] + +# Regression tests for https://github.com/python/typeshed/pull/16299 +assert_type(int.__subclasses__(), list[type[int]]) +assert_type(str.__subclasses__(), list[type[str]]) +assert_type(BaseException.__subclasses__(), list[type[BaseException]]) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 3c549d97316c..903b13aa460a 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -218,7 +218,7 @@ class type: ) -> _typeshed.Self: ... def __call__(self, *args: Any, **kwds: Any) -> Any: ... - def __subclasses__(self: _typeshed.Self) -> list[_typeshed.Self]: ... + def __subclasses__(self: type[_T]) -> list[type[_T]]: ... # Note: the documentation doesn't specify what the return type is, the standard # implementation seems to be returning a list. def mro(self) -> list[type]: ...