Title: `TextIOWrapper` stub does not match stdlib documentation · Issue #6061 · python/typeshed · GitHub
Open Graph Title: `TextIOWrapper` stub does not match stdlib documentation · Issue #6061 · python/typeshed
X Title: `TextIOWrapper` stub does not match stdlib documentation · Issue #6061 · python/typeshed
Description: The official documentation for TextIOWrapper implies that the underlying buffer is an instance of (or implements the interface of) io.BufferedIOBase, but typeshed annotates it as IO[bytes], leading to the following counterintuitive behav...
Open Graph Description: The official documentation for TextIOWrapper implies that the underlying buffer is an instance of (or implements the interface of) io.BufferedIOBase, but typeshed annotates it as IO[bytes], leading...
X Description: The official documentation for TextIOWrapper implies that the underlying buffer is an instance of (or implements the interface of) io.BufferedIOBase, but typeshed annotates it as IO[bytes], leading...
Opengraph URL: https://github.com/python/typeshed/issues/6061
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`TextIOWrapper` stub does not match stdlib documentation","articleBody":"The [official documentation for `TextIOWrapper`](https://docs.python.org/3/library/io.html#io.TextIOWrapper) implies that the underlying `buffer` is an instance of (or implements the interface of) `io.BufferedIOBase`, but typeshed [annotates it as `IO[bytes]`](https://github.com/python/typeshed/blob/master/stdlib/io.pyi#L136), leading to the following counterintuitive behavior:\r\n\r\n```python\r\n# repro.py\r\nimport typing\r\nfrom io import TextIOWrapper, BufferedIOBase\r\n\r\ndef badfunc(stream: BufferedIOBase) -> TextIOWrapper:\r\n return TextIOWrapper(stream)\r\n\r\ndef goodfunc(stream: typing.IO[bytes]) -> TextIOWrapper:\r\n return TextIOWrapper(stream)\r\n```\r\n\r\n```\r\n18:12 [snoopjedi@denton ~]\r\n$ python3 -m mypy repro.py \r\nrepro.py:6: error: Argument 1 to \"TextIOWrapper\" has incompatible type \"BufferedIOBase\"; expected \"IO[bytes]\"\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nThis example is reduced from a question a user asked in the #python IRC channel on Libera.net, regarding [this user code](https://github.com/iafork/rdflib/blob/iwana-20210912T2356/rdflib/plugins/serializers/turtle.py#L239-L241) in `rdflib`.\r\n\r\n### Version information\r\n\r\n```\r\n18:12 [snoopjedi@denton ~]\r\n$ python3 -m mypy --version\r\nmypy 0.910\r\n18:12 [snoopjedi@denton ~]\r\n$ python3 -V\r\nPython 3.8.10\r\n\r\n```","author":{"url":"https://github.com/SnoopJ","@type":"Person","name":"SnoopJ"},"datePublished":"2021-09-21T22:15:33Z","url":"https://github.com/python/typeshed/issues/6061"}
| 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:6a3bb460-37bc-f03f-09ee-f078850a0acc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A616:396A8E:14C9C7B:1B83E64:6B001BCD |
| html-safe-nonce | b1f56346b6891909634e7b7d0ffe44c74052b9f4aca3cce280ea94ab3c5ae63a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjE2OjM5NkE4RToxNEM5QzdCOjFCODNFNjQ6NkIwMDFCQ0QiLCJ2aXNpdG9yX2lkIjoiODQ5ODcxOTU3NzMwNjMwNzUzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fd2f6fd6948c92cc75676838f83cecb3bd080d8377ce3e1137a55b123b059a0e |
| hovercard-subject-tag | issue:1003380924 |
| 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/6061/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a8b64dc4d156056763874ba7e923c0d1fd44d74b0c7b5ccf4a88b74139cccbcc/python/typeshed/issues/6061 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a8b64dc4d156056763874ba7e923c0d1fd44d74b0c7b5ccf4a88b74139cccbcc/python/typeshed/issues/6061 |
| og:image:alt | The official documentation for TextIOWrapper implies that the underlying buffer is an instance of (or implements the interface of) io.BufferedIOBase, but typeshed annotates it as IO[bytes], leading... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SnoopJ |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width