You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Assume there is no bytes/bytearray/memoryview implicit promotion #9001
Currently, we treat bytearray and memoryview as implicit subclasses of bytes, following the CPython documentation. In PEP 688, I propose to remove this implicit promotion. Discussion is still ongoing, but I'd like to make sure typeshed is ready for this change by reviewing existing usage of bytes.
To make that easier, I propose that we write stubs as if there is no implicit promotion between bytes, bytearray, and memoryview. Thus, if a function accepts either bytes or bytearray, we should write bytes | bytearray, not just bytes.
The only cost here should be that certain argument annotations become longer; everything should still work fine for type checkers that assume the implicit promotion.
If we agree on this rule, I can review existing bytes annotations for correctness. In my experience, most usages of bytes in argument positions should be ReadableBuffer.
Hopefully most of them will be fairly easy. I'll update our docs to reflect this convention, then open a new issue with a TODO list for reviewing the stubs.
Activity
srittau commentedon Oct 27, 2022
Sounds good, but this is quite a large task:
JelleZijlstra commentedon Oct 27, 2022
Hopefully most of them will be fairly easy. I'll update our docs to reflect this convention, then open a new issue with a TODO list for reviewing the stubs.
Add options to disable bytes promotion
Add hidden options to disable bytes promotion (#13952)
Add hidden options to disable bytes promotion (#13952)
CONTRIBUTING: Note no bytearray promotion
CONTRIBUTING: Note no bytearray promotion (#9005)