-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
gh-101100: Fix sphinx reference warnings around I/O #139592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Resolves 7 warnings. Generally: "file object" -> IOBase; "binary"/`byte` read/write -> BufferedIOBase, "text"/`str` read/write -> TextIOBase Specific cases: - `EOFError` is for `input` builtin function which reads a `str`, so `TextIOBase` - `os.read` and `os.write` speak bytes but the sentence is about `sys.stdin` and `sys.stdout` which are `TextIOBase`; use the function that gets called by `sys.stdout.write`. - `os.exec`: `flush` is talking about files generally, so `IOBase` - `email.parser` is talking about binary files / `bytes` so `BufferedIOBase`
|
I think this makes sense since read and write aren't defined on @AA-Turner wondering if you have thoughts on the best path forward here. |
|
Though at runtime, >>> io.IOBase.read
Traceback (most recent call last):
File "...", line 1, in <module>
io.IOBase.read
AttributeError: type object 'IOBase' has no attribute 'read'I worry it'd be confusing to 'lie' here, given that there's somewhat of a conflict: in one place we note that it is Eliding the signatures entirely ought to work, i.e.: .. method:: IOBase.read
... spam spam spam spam ham eggs and spam ...A |
|
re: Common definition, I'm open to but worry it will be hard to express the three different variants of "write" (and "read") concisely:
Scanning through github repos (including CPython which caches I have as a general project to clarify the I/O docs around read/write more (they don't match shipping behavior, ex more than one system call may be made in Raw I/O; gh-129011). That's a lot more intricate as it needs to also cover |
|
What would you think of putting a generic It feels like they're concepts that are replicated a lot in Python code. Another option would be https://docs.python.org/3/library/io.html#static-typing which defines a generic read and write, but understanding that doc to me requires a lot more knowledge someone learning about |
|
This almost feels a better fit for the data model (in the PLR). We already have pseudo definitions for 'protocols', eg for A |
|
@emmatyping , @AA-Turner I added |
Co-authored-by: Carol Willing <[email protected]>
emmatyping
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good, thank you!
|
Pre-merge I'd like either @AA-Turner review on the Python Language Reference change or to pull that out (and do a separate issue for it an refactoring more broadly possibly) |
willingc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm satisfied with the language ref change will leave for @AA-Turner to re-review and merge.
Resolves 7 warnings.
Generally: "file object" -> IOBase; "binary"/
byteread/write ->BufferedIOBase, "text"/strread/write ->TextIOBaseMy reasoning for specific cases (happy to change):
EOFErroris forinputbuiltin function which reads astr, soTextIOBaseos.readandos.writespeak bytes but the sentence is aboutsys.stdinandsys.stdoutwhich areTextIOBase; use the function that gets called bysys.stdout.write(TextIOBase.write).os.exec:flushis talking about files generally, soIOBaseemail.parseris talking about binary files /bytessoBufferedIOBase📚 Documentation preview 📚: https://cpython-previews--139592.org.readthedocs.build/