Skip to content

Allow overlapping comparisons between bytes-like types#14658

Merged
JukkaL merged 1 commit intopython:masterfrom
hauntsaninja:overlapping-bytes
Feb 9, 2023
Merged

Allow overlapping comparisons between bytes-like types#14658
JukkaL merged 1 commit intopython:masterfrom
hauntsaninja:overlapping-bytes

Conversation

@hauntsaninja
Copy link
Copy Markdown
Collaborator

No description provided.

@JelleZijlstra
Copy link
Copy Markdown
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
Copy Markdown
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.

3 participants