docs: add missing docstrings for public API#3404
docs: add missing docstrings for public API#3404nightcityblade wants to merge 5 commits intopython-trio:mainfrom
Conversation
Add docstrings to: - MemorySendChannel class - MemoryReceiveChannel class - MemoryChannelStatistics class and attributes - SocketStream.send_all, wait_send_all_might_not_block, send_eof, receive_some, aclose - HasFileno.fileno - ParkingLot.broken_by attribute Fixes python-trio#3221
|
See discussion in #3388 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3404 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 128 128
Lines 19424 19418 -6
Branches 1318 1318
===============================================
- Hits 19424 19418 -6
🚀 New features to boost your workflow:
|
|
BTW please make CI pass! |
|
Fixed! I've updated the type completeness checklist to remove the entries that are now resolved by the new docstrings. CI should pass now. |
|
Need to update type completeness file, you need to do |
|
Thanks @CoolCat467! I ran |
|
Thanks for the feedback @A5rocks @CoolCat467! I've rebased on upstream/main and am working on getting the type_completeness check to pass. The docstrings are present at runtime but pyright's |
The current CI errors are
|
|
Thanks @jakkdl for the detailed feedback! I'll address all four points:
Will push the fixes shortly. |
…type completeness json
|
still have RTD failures docstring of trio.MemorySendChannel:4: WARNING: undefined label: 'channel' [ref.ref]
docstring of trio.MemoryReceiveChannel:4: WARNING: undefined label: 'channel' [ref.ref] |
The labels in reference-core.rst use 'channels' (plural), but the MemorySendChannel and MemoryReceiveChannel docstrings referenced 'channel' (singular), causing RTD build warnings.
|
Fixed the RTD warnings — the docstrings in |
| # items | ||
| _parked: OrderedDict[Task, None] = attrs.field(factory=OrderedDict, init=False) | ||
| broken_by: list[Task] = attrs.field(factory=list, init=False) | ||
| """List of tasks that have broken this parking lot via |
There was a problem hiding this comment.
It looks like you tried to document broken_by... but Sphinx didn't pick it up (see your docs/source/conf.py change).
| open_receive_channels: The number of open | ||
| :class:`MemoryReceiveChannel` endpoints. | ||
| tasks_waiting_send: The number of tasks waiting to send. | ||
| tasks_waiting_receive: The number of tasks waiting to receive. |
There was a problem hiding this comment.
If MemorySendChannel.statistics and MemoryReceiveChannel.statistics document the attributes (iirc they do), could you remove that?
(well, that's my current mood. but I'm not so sure which way is best!)
| :func:`open_memory_channel`. | ||
|
|
||
| See :ref:`channels` for details. This implements the | ||
| :class:`trio.abc.SendChannel` interface. |
There was a problem hiding this comment.
IMO "this implements ..." is unnecessary. Do we do that elsewhere?
| :func:`open_memory_channel`. | ||
|
|
||
| See :ref:`channels` for details. This implements the | ||
| :class:`trio.abc.ReceiveChannel` interface. |
| self.setsockopt(tsocket.IPPROTO_TCP, tsocket.TCP_NOTSENT_LOWAT, 2**14) | ||
|
|
||
| async def send_all(self, data: bytes | bytearray | memoryview) -> None: | ||
| """See :meth:`trio.abc.SendStream.send_all`.""" |
There was a problem hiding this comment.
That's strange, why is Sphinx making you copy-paste these? Hmmm... maybe it's the undoc-members here?
trio/docs/source/reference-io.rst
Line 221 in 94d7159
I would rather fix that there instead of adding docstrings here.
Fixes #3221
Adds docstrings to the following public API items that were showing up without documentation:
MemorySendChannel— class docstring referencingopen_memory_channelMemoryReceiveChannel— class docstring referencingopen_memory_channelMemoryChannelStatistics— class docstring with attribute descriptionsSocketStream.send_all,wait_send_all_might_not_block,send_eof,receive_some,aclose— short docstrings referencing the parent ABC methodsHasFileno.fileno— method docstringParkingLot.broken_by— attribute docstringThe SocketStream method docstrings use
See :meth:...cross-references rather than duplicating the ABC documentation, keeping them in sync with the parent class.Tests run:
pytest src/trio/_tests/test_channel.py src/trio/_tests/test_highlevel_socket.py src/trio/_core/_tests/test_parking_lot.py— all pass.