Title: Add a command line switch to disable bytes aliasing · Issue #12657 · python/mypy · GitHub
Open Graph Title: Add a command line switch to disable bytes aliasing · Issue #12657 · python/mypy
X Title: Add a command line switch to disable bytes aliasing · Issue #12657 · python/mypy
Description: Feature Please add a command line and configuration parameter --disable-bytes-alias to avoid Mypy to consider bytes an alias for bytearray and memoryview. Pitch In the documentation of typing.ByteString, a little footnote probably, enter...
Open Graph Description: Feature Please add a command line and configuration parameter --disable-bytes-alias to avoid Mypy to consider bytes an alias for bytearray and memoryview. Pitch In the documentation of typing.ByteS...
X Description: Feature Please add a command line and configuration parameter --disable-bytes-alias to avoid Mypy to consider bytes an alias for bytearray and memoryview. Pitch In the documentation of typing.ByteS...
Opengraph URL: https://github.com/python/mypy/issues/12657
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a command line switch to disable bytes aliasing","articleBody":"**Feature**\r\n\r\nPlease add a command line and configuration parameter `--disable-bytes-alias` to avoid Mypy to consider `bytes` an alias for `bytearray` and `memoryview`.\r\n\r\n**Pitch**\r\n\r\nIn the documentation of [`typing.ByteString`](https://docs.python.org/3/library/typing.html#typing.ByteString), a little footnote probably, entered by the author's cat walking on the keyboard and entering random keypresses, says that `bytes` can be used as a shorthand to represent unrelated types such as `memoryview`, which have a different interface. See #12643.\r\n\r\nAs a result, it is not possible to obtain reliable code analysis on code using different `ByteString` types, such as:\r\n\r\n```python\r\n\r\ndef f(data: ByteString) -> str:\r\n if not isinstance(data, bytes):\r\n data = bytes(data)\r\n\r\n return data.decode()\r\n```\r\n\r\nMypy will report that the `if` branch will never be executed, then it will proceed to complain that `memoryview` doesn't have a `decode()` method.\r\n\r\nIt would be nice to have this behaviour deprecated and eventually removed and forgotten (no harm intended to the cat). However, as this is a long process, it would be nice to give developers the possibility to disable this ill-thought rule sooner.\r\n","author":{"url":"https://github.com/dvarrazzo","@type":"Person","name":"dvarrazzo"},"datePublished":"2022-04-22T17:09:59Z","url":"https://github.com/python/mypy/issues/12657"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:4d5e2102-3f60-3af0-4af7-b9e9ece615e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9484:102136:2A69EF:38DD61:6B002536 |
| html-safe-nonce | 141666886425c8b61fb13219683a3ed67804008575a31c1548cf2f9e8ad1bc54 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDg0OjEwMjEzNjoyQTY5RUY6MzhERDYxOjZCMDAyNTM2IiwidmlzaXRvcl9pZCI6IjY2ODk3Mzc1NDQ3NDMwMDM0NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 849d1aac5b9729592c7f8864620eb92cb88833877af4b7475f73a79e17480cfb |
| hovercard-subject-tag | issue:1212590903 |
| 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/mypy/12657/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fefaa615a914ba9a5d0bf98fc0f9efc9cd80c6299f0a24d4c288fca02d02a9be/python/mypy/issues/12657 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fefaa615a914ba9a5d0bf98fc0f9efc9cd80c6299f0a24d4c288fca02d02a9be/python/mypy/issues/12657 |
| og:image:alt | Feature Please add a command line and configuration parameter --disable-bytes-alias to avoid Mypy to consider bytes an alias for bytearray and memoryview. Pitch In the documentation of typing.ByteS... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dvarrazzo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width