diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 1e50be185b03..d8956df6b327 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -237,7 +237,6 @@ asyncio.locks.Condition.release builtins.memoryview.__contains__ # C type that implements __getitem__ builtins.reveal_locals # Builtins that type checkers pretends exist builtins.reveal_type # Builtins that type checkers pretends exist -builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute. # The following CodecInfo properties are added in __new__ codecs.CodecInfo.decode diff --git a/stdlib/@tests/test_cases/builtins/check_type.py b/stdlib/@tests/test_cases/builtins/check_type.py new file mode 100644 index 000000000000..1eafcf482fb6 --- /dev/null +++ b/stdlib/@tests/test_cases/builtins/check_type.py @@ -0,0 +1,4 @@ +class Meta(type): ... + + +call = Meta.__dict__["__call__"] diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 1bc46493338c..835ab3a74c44 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -42,6 +42,7 @@ from typing import ( # noqa: Y022,UP035 Any, BinaryIO, ClassVar, + Final, Generic, Mapping, MutableMapping, @@ -189,8 +190,9 @@ class type: __bases__: tuple[type, ...] @property def __basicsize__(self) -> int: ... - @property - def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override] + # type.__dict__ is read-only at runtime, but that can't be expressed currently. + # See https://github.com/python/typeshed/issues/11033 for a discussion. + __dict__: Final[types.MappingProxyType[str, Any]] # type: ignore[assignment] @property def __dictoffset__(self) -> int: ... @property