Add BytesIO alias to fix missing references in docs#7737
Add BytesIO alias to fix missing references in docs#7737nulano wants to merge 1 commit intopython-pillow:mainfrom
Conversation
Do you know where this is coming from? |
|
This name can be observed from the console: Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> io.BytesIO
<class '_io.BytesIO'>However, it is listed under I'm not sure if this would qualify as a CPython bug, a docs.python.org bug, or a sphinx autodoc bug. |
|
I wonder what's changed for it to start happening now? The last Python releases were in December, and Sphinx was in September. The direct docs dependencies also haven't recently changed. It feels like something that should be fixed upstream, somewhere, if possible... |
|
|
||
| # io.BytesIO is incorrectly converted to _io.BytesIO, this alias prevents that | ||
| autodoc_type_aliases = { | ||
| "BytesIO": "~io.BytesIO", |
There was a problem hiding this comment.
| "BytesIO": "~io.BytesIO", | |
| "BytesIO": "io.BytesIO", |
I find that the tilde isn't necessary? radarhere@f698cb9 / https://github.com/radarhere/Pillow/actions/runs/7599204419/job/20695972684
There was a problem hiding this comment.
The tilde is for consistency with other types.
With the tilde:

Compare with e.g. typing.BinaryIO:

|
Closing, in favour of #7750 |

A warning has started appearing in the Docs build in main due to type hints added in #7727 and #7728.
This PR fixes it using
autodoc_type_aliases.