Skip to content

Commit be34e92

Browse files
authored
Change type.__dict__ to a proper attribute (#14951)
1 parent bf72147 commit be34e92

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

stdlib/@tests/stubtest_allowlists/common.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ asyncio.locks.Condition.release
237237
builtins.memoryview.__contains__ # C type that implements __getitem__
238238
builtins.reveal_locals # Builtins that type checkers pretends exist
239239
builtins.reveal_type # Builtins that type checkers pretends exist
240-
builtins.type.__dict__ # read-only but not actually a property; stubtest thinks it's a mutable attribute.
241240

242241
# The following CodecInfo properties are added in __new__
243242
codecs.CodecInfo.decode
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Meta(type): ...
2+
3+
4+
call = Meta.__dict__["__call__"]

stdlib/builtins.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ from typing import ( # noqa: Y022,UP035
4242
Any,
4343
BinaryIO,
4444
ClassVar,
45+
Final,
4546
Generic,
4647
Mapping,
4748
MutableMapping,
@@ -189,8 +190,9 @@ class type:
189190
__bases__: tuple[type, ...]
190191
@property
191192
def __basicsize__(self) -> int: ...
192-
@property
193-
def __dict__(self) -> types.MappingProxyType[str, Any]: ... # type: ignore[override]
193+
# type.__dict__ is read-only at runtime, but that can't be expressed currently.
194+
# See https://github.com/python/typeshed/issues/11033 for a discussion.
195+
__dict__: Final[types.MappingProxyType[str, Any]] # type: ignore[assignment]
194196
@property
195197
def __dictoffset__(self) -> int: ...
196198
@property

0 commit comments

Comments
 (0)