GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — builtins: Audit bytes arguments by JelleZijlstra · Pull Request #7631 · python/typeshed Conversation
Member
As a followup from #7589 (comment), Most use the C buffer protocol, so _typeshed.ReadableBuffer is the right type. A few
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsAs a followup from python#7589 (comment), I audited all occurrences of bytes in builtins.pyi by reading the corresponding C code on CPython main. Most use the C buffer protocol, so _typeshed.ReadableBuffer is the right type. A few check specifically for bytes and bytearray.
JelleZijlstra
commented
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Showing that the first overload accepts buffers but the second doesn't.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was wrong;
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
This comment has been minimized.
This comment has been minimized.
|
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I didn't double check, but the changes look reasonable.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| def join(self, __iterable_of_bytes: Iterable[ByteString | memoryview]) -> bytes: ... | ||
| def ljust(self, __width: SupportsIndex, __fillchar: bytes = ...) -> bytes: ... | ||
| def join(self, __iterable_of_bytes: Iterable[ReadableBuffer]) -> bytes: ... | ||
| def ljust(self, __width: SupportsIndex, __fillchar: bytes | bytearray = ...) -> bytes: ... |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this will also accept memoryview at the moment, but having it more explicit can't hurt.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That's a mypy bug :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's working as documented. In the past when reviewing I've always asked people to remove bytearray from argument types due to that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.