Skip to content
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

Allow overlapping comparisons between bytes-like types #14658

Merged
merged 1 commit into from Feb 9, 2023

Conversation

hauntsaninja
Copy link
Collaborator

No description provided.

@JelleZijlstra
Copy link
Member

Thanks for noticing this!

The actual runtime behavior is that bytes returns NotImplemented for anything that's not bytes, but both bytearray and memoryview support comparison with any other buffer. That behavior isn't representable in the type system until we have PEP 688, so what your PR does seems like a step in the right direction.

Would mypy --strict-equality work without special casing if we added def __eq__(self, other: ReadableBuffer) to memoryview and bytearray in typeshed?

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

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

@JukkaL JukkaL merged commit c23e831 into python:master Feb 9, 2023
@hauntsaninja hauntsaninja deleted the overlapping-bytes branch February 11, 2023 01:46
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.

None yet

3 participants