Skip to content

Commit d5b88c5

Browse files
authored
Add __eq__ to types.MappingProxyType (#9580)
The type has a custom __eq__: https://github.com/python/cpython/blob/v3.11.1/Objects/descrobject.c#L1906 This helps fix this mypy false positive when using `--strict-equality`: ``` from types import MappingProxyType p = MappingProxyType({'x': 1}) d = {'x': 1} print(p == d) # error: Non-overlapping equality check ``` The fragment prints `True` so the comparison is valid.
1 parent ebba92c commit d5b88c5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ class MappingProxyType(Mapping[_KT, _VT_co], Generic[_KT, _VT_co]):
310310
def __getitem__(self, __key: _KT) -> _VT_co: ...
311311
def __iter__(self) -> Iterator[_KT]: ...
312312
def __len__(self) -> int: ...
313+
def __eq__(self, other: object) -> bool: ...
313314
def copy(self) -> dict[_KT, _VT_co]: ...
314315
def keys(self) -> KeysView[_KT]: ...
315316
def values(self) -> ValuesView[_VT_co]: ...

0 commit comments

Comments
 (0)