Title: collections.abc.ByteString is not equivalent to typing.ByteString · Issue #102092 · python/cpython · GitHub
Open Graph Title: collections.abc.ByteString is not equivalent to typing.ByteString · Issue #102092 · python/cpython
X Title: collections.abc.ByteString is not equivalent to typing.ByteString · Issue #102092 · python/cpython
Description: There are two related, but different strands of conversation here: collections.abc.ByteString is useless and confusing: #91896 That bytes can be used as a shorthand for typing.ByteString and includes memoryview and bytearray https://peps...
Open Graph Description: There are two related, but different strands of conversation here: collections.abc.ByteString is useless and confusing: #91896 That bytes can be used as a shorthand for typing.ByteString and includ...
X Description: There are two related, but different strands of conversation here: collections.abc.ByteString is useless and confusing: #91896 That bytes can be used as a shorthand for typing.ByteString and includ...
Opengraph URL: https://github.com/python/cpython/issues/102092
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"collections.abc.ByteString is not equivalent to typing.ByteString","articleBody":"There are two related, but different strands of conversation here:\r\n- `collections.abc.ByteString` is useless and confusing: https://github.com/python/cpython/issues/91896\r\n- That `bytes` can be used as a shorthand for `typing.ByteString` and includes `memoryview` and `bytearray` https://peps.python.org/pep-0688/\r\n\r\nHowever, there is an additional issue! `collections.abc.ByteString` is not an accurate replacement for `typing.ByteString`! `collections.abc.ByteString` only registers `bytes` and `bytearray`, whereas `typing.ByteString` is documented as also representing a memoryview. This is an issue regardless of the above two related conversations.\r\n\r\nFor this issue we could:\r\n- Move the documentation of `typing.ByteString` out from under the \"Corresponding to collections in collections.abc\" section to the \"Other concrete types\" section\r\n- Remove all mention of `collections.abc.ByteString` from typing.rst\r\n- Keep the mention of `typing.ByteString` as being deprecated, but change the reason. ByteString is not a generic type and `collections.abc.ByteString` is not a semantic replacement for it as above, so the current reason is wrong on two counts\r\n- Define `typing.ByteString` in typeshed as a simple Union, and not the Sequence[int] thing it is right now. \r\n- Define `typing.ByteString` as a Union in typing.py instead of the generic alias it is now(?)\r\n\r\nHere's how this relates to the other two strands of conversation:\r\n- We should also remove the note about the bytes shorthand from the docs\r\n- We should deprecate both `typing.ByteString` and `collections.abc.ByteString`. I'm fine with going slow on the removal of `typing.ByteString`, since once it's a union in typeshed it's not causing much harm. But ideally we can remove `collections.abc.ByteString` in 3.14, since its isinstance behaviour is not what you want.\r\n\r\ncc @JelleZijlstra ","author":{"url":"https://github.com/hauntsaninja","@type":"Person","name":"hauntsaninja"},"datePublished":"2023-02-20T22:27:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/102092/cpython/issues/102092"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:27a6f46b-1d5e-ed8d-ac0e-fc91e5dd21d0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6A4:97651:6B8BA1:915290:6969DA03 |
| html-safe-nonce | 007187d84e467e424e8b855c3f34c9f88becbf20ce40330e092e32ece9e43635 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkE0Ojk3NjUxOjZCOEJBMTo5MTUyOTA6Njk2OURBMDMiLCJ2aXNpdG9yX2lkIjoiNDAzNDM4OTI0ODIxMzM3NTQ5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2af885fe75554df9b8ad29e1032a092dafda99764158c8bc9d32b118d8a0fe88 |
| hovercard-subject-tag | issue:1592515864 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/102092/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3e85afc5b58b2605a0e7551a4436992f9076ad56355c92a4b1ad36882bc24f9b/python/cpython/issues/102092 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3e85afc5b58b2605a0e7551a4436992f9076ad56355c92a4b1ad36882bc24f9b/python/cpython/issues/102092 |
| og:image:alt | There are two related, but different strands of conversation here: collections.abc.ByteString is useless and confusing: #91896 That bytes can be used as a shorthand for typing.ByteString and includ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hauntsaninja |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width