Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add __eq__ to types.MappingProxyType #9580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2023
Merged

Conversation

JukkaL
Copy link
Contributor

@JukkaL JukkaL commented Jan 23, 2023

The type has a custom rich comparison function:
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.

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.
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood merged commit d5b88c5 into python:main Jan 23, 2023
AlexWaygood added a commit that referenced this pull request Jan 23, 2023
The second parameter is positional-only (I missed this when reviewing #9580)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants