Title: Argument 1 to "TextIOWrapper" has incompatible type "IO[bytes]"; expected "BinaryIO" · Issue #4349 · python/typeshed · GitHub
Open Graph Title: Argument 1 to "TextIOWrapper" has incompatible type "IO[bytes]"; expected "BinaryIO" · Issue #4349 · python/typeshed
X Title: Argument 1 to "TextIOWrapper" has incompatible type "IO[bytes]"; expected "BinaryIO" · Issue #4349 · python/typeshed
Description: I see that there's work going on for IO types so maybe this is WIP or maybe it's an unintended regression. This minimal test case: import io from typing import IO def test1(binary_file): # type: (IO[bytes]) -> IO[str] text_file = io.Text...
Open Graph Description: I see that there's work going on for IO types so maybe this is WIP or maybe it's an unintended regression. This minimal test case: import io from typing import IO def test1(binary_file): # type: (I...
X Description: I see that there's work going on for IO types so maybe this is WIP or maybe it's an unintended regression. This minimal test case: import io from typing import IO def test1(binary_file): # ...
Opengraph URL: https://github.com/python/typeshed/issues/4349
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Argument 1 to \"TextIOWrapper\" has incompatible type \"IO[bytes]\"; expected \"BinaryIO\"","articleBody":"I see that there's work going on for IO types so maybe this is WIP or maybe it's an unintended regression.\r\n\r\nThis minimal test case:\r\n\r\n```python\r\nimport io\r\nfrom typing import IO\r\n\r\n\r\ndef test1(binary_file):\r\n # type: (IO[bytes]) -> IO[str]\r\n text_file = io.TextIOWrapper(binary_file, encoding='utf-8', newline='')\r\n return text_file\r\n\r\ndef test2():\r\n # type: () -> IO[str]\r\n binary_file = io.open('foo.bin', 'rb')\r\n return test1(binary_file)\r\n\r\ndef test3():\r\n # type: () -> IO[str]\r\n binary_file = io.open('foo.bin', 'rb')\r\n text_file = io.TextIOWrapper(binary_file, encoding='utf-8', newline='')\r\n return text_file\r\n```\r\n\r\ntype checks fine with mypy 0.770 whereas mypy 0.780 and 0.782 issue these errors:\r\n\r\n```\r\ntest_mypy_io.py:7:34: error: Argument 1 to \"TextIOWrapper\" has incompatible type \"IO[bytes]\"; expected \"BinaryIO\" [arg-type]\r\ntest_mypy_io.py:18:34: error: Argument 1 to \"TextIOWrapper\" has incompatible type \"IO[Any]\"; expected \"BinaryIO\" [arg-type]\r\n```\r\n\r\nDoesn't `io.open('foo.bin', 'rb')` return exactly the right type to pass to `io.TextIOWrapper()`.\r\n\r\nAm I misunderstanding the types?\r\n\r\nThanks for all your contributions, people!!","author":{"url":"https://github.com/1fish2","@type":"Person","name":"1fish2"},"datePublished":"2020-07-21T06:04:49Z","url":"https://github.com/python/typeshed/issues/4349"}
| 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:8b95f6f1-535d-b0e1-4827-e832460bd7f7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AAA6:2AD163:1FDEDFC:2B3B6AE:6B001A46 |
| html-safe-nonce | 2f743fd6ceb76f49a9ff67055358b6e55e3ba048d859ec9aec47149f84d8b7fb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUE2OjJBRDE2MzoxRkRFREZDOjJCM0I2QUU6NkIwMDFBNDYiLCJ2aXNpdG9yX2lkIjoiNzk1NjQwNTMzNTQyNDUwNjQzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 057becefc736bee80de2cb07705b168ecc80cb92f3aba49c79e2601e0560bc5f |
| hovercard-subject-tag | issue:662630866 |
| 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/typeshed/4349/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86b932506e28189c81373f88224bbd5c323f6b18b7d147425c8a73a8cc1ae50c/python/typeshed/issues/4349 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86b932506e28189c81373f88224bbd5c323f6b18b7d147425c8a73a8cc1ae50c/python/typeshed/issues/4349 |
| og:image:alt | I see that there's work going on for IO types so maybe this is WIP or maybe it's an unintended regression. This minimal test case: import io from typing import IO def test1(binary_file): # type: (I... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 1fish2 |
| hostname | github.com |
| expected-hostname | github.com |
| None | a2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 70121d4e855ee0bb7b75cf15d061d91f8863c0f8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width