Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
def2793
add docstring to types that are mentioned in public interface; remove…
CheViana Sep 22, 2026
e699edf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2026
77431bf
fix sphinx docs, add newsfragment
CheViana Sep 22, 2026
9f7cf26
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 22, 2026
7b5ff58
shorter docstring
CheViana Sep 22, 2026
4357f79
Merge branch 'fix/issue-3226-docstrings' of https://github.com/CheVia…
CheViana Sep 22, 2026
c412c93
fix print with missing var
CheViana Sep 22, 2026
077db9a
Update 3226.bugfix.rst
CheViana Sep 24, 2026
e12f14e
print missing_names for debug
CheViana Sep 24, 2026
d6a1c23
fix prints
Sep 25, 2026
75b5048
debug test_exports.py where ALG_SET_PUB_KEY is from?
CheViana Sep 26, 2026
61f6fe1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2026
ff19be6
remove debugs from test_Exports.py
Sep 26, 2026
a9c50d5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2026
18ab531
exclude missing name with typo per bug in pypy
Sep 26, 2026
4d52bc7
Merge branch 'fix/issue-3226-docstrings' of https://github.com/CheVia…
CheViana Sep 26, 2026
5ff554f
pin pypy to 7.3 for windows
Sep 26, 2026
a20ef57
pip install verbose
Sep 30, 2026
f376ae4
Merge branch 'main' into fix/issue-3226-docstrings
CheViana Sep 30, 2026
715c75c
verbose pip install
CheViana Sep 30, 2026
fdc413b
merge, bump crypto
Sep 30, 2026
b042f69
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2026
e71c0dd
exclude one more name
Sep 30, 2026
0a221e4
Merge branch 'fix/issue-3226-docstrings' of https://github.com/CheVia…
CheViana Sep 30, 2026
32b12b0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 30, 2026
e01363a
Revert "merge, bump crypto"
CheViana Oct 1, 2026
557cea1
Revert "remove debugs from test_Exports.py"
CheViana Oct 1, 2026
c29d393
merge main
Oct 1, 2026
614d6ab
Avoid SSL tests on x86 Windows as cryptography doesn't support it (#3…
A5rocks Sep 30, 2026
d0bb1a4
remove debug code and fix reqs
CheViana Oct 1, 2026
3cd8d7f
fix rst formatting
Oct 1, 2026
f1561ee
beautify IOStatistics docstrings
Oct 1, 2026
268ea76
beautify other docstrings
Oct 1, 2026
7c81d78
shorter newsfragment
CheViana Oct 1, 2026
563c1b2
touch to rerun CI
CheViana Oct 1, 2026
ac8efc5
revert check_type_completeness.py and bring back empty json
CheViana Oct 2, 2026
5d1104a
revert check_type_completeness.py and bring back empty json
CheViana Oct 2, 2026
a8851f4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2026
c307cab
polish docs, remove outdated entries
CheViana Oct 2, 2026
55e796b
Merge branch 'fix/issue-3226-docstrings' of https://github.com/CheVia…
CheViana Oct 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def autodoc_process_signature(
# currently undocumented things
logger = getLogger("trio")
UNDOCUMENTED = {
"trio._subprocess.HasFileno.fileno",
"trio.lowlevel.ParkingLot.broken_by",
}

Expand Down
1 change: 1 addition & 0 deletions newsfragments/3226.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add docstrings that ``pyright --verifytypes`` complains about.
26 changes: 26 additions & 0 deletions src/trio/_core/_io_epoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ class EpollWaiters:

@attrs.frozen(eq=False)
class _EpollStatistics:
"""DTO class that holds information on current epoll status.

This class can be used on any platform that supports
epoll functionality (e.g. Linux).
Trio also defines other similar classes for statistics reporting:
``_WindowsStatistics`` and ``_KqueueStatistics``.
They are similar in function but some fields differ.
All of them have a ``backend`` attribute.
The statistics class best suited for the runtime platform is
imported as the ``IOStatistics`` type. See ``trio._core._run``.

.. attribute:: tasks_waiting_read

Number of tasks waiting on read.

.. attribute:: tasks_waiting_write

Number of tasks waiting on write.

.. attribute:: backend

This attribute holds a string value that corresponds to the statistics type.
This class has ``backend == "epoll"``.
Use ``backend`` attribute to distinguish statistics types at runtime.
"""

tasks_waiting_read: int
tasks_waiting_write: int
backend: Literal["epoll"] = attrs.field(init=False, default="epoll")
Expand Down
26 changes: 26 additions & 0 deletions src/trio/_core/_io_kqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@

@attrs.frozen(eq=False)
class _KqueueStatistics:
"""DTO class that holds information on current kqueue status.

This class can be used on any platform that supports
kqueue functionality (e.g. BSD/Darwin).
Trio also defines other similar classes for statistics reporting:
``_WindowsStatistics`` and ``_EpollStatistics``.
They are similar in function but some fields differ.
All of them have a ``backend`` attribute.
The statistics class best suited for the runtime platform is
imported as the ``IOStatistics`` type. See ``trio._core._run``.

.. attribute:: tasks_waiting

Number of tasks that are currently in the waiting state.

.. attribute:: monitors

Number of monitors.

.. attribute:: backend

This attribute holds a string value that corresponds to the statistics type.
This class has ``backend == "kqueue"``.
Use ``backend`` attribute to distinguish statistics types at runtime.
"""

tasks_waiting: int
monitors: int
backend: Literal["kqueue"] = attrs.field(init=False, default="kqueue")
Expand Down
33 changes: 33 additions & 0 deletions src/trio/_core/_io_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,39 @@ class AFDGroup:

@attrs.frozen(eq=False)
class _WindowsStatistics:
"""DTO class that holds information on current I/O waits status.

This class is used on the Windows platform.
Trio also defines other similar classes for statistics reporting:
``_KqueueStatistics`` and ``_EpollStatistics``.
They are similar in function but some fields differ.
All of them have a ``backend`` attribute.
The statistics class best suited for the runtime platform is
imported as the ``IOStatistics`` type. See ``trio._core._run``.

.. attribute:: tasks_waiting_read

Number of tasks waiting on read.

.. attribute:: tasks_waiting_write

Number of tasks waiting on write.

.. attribute:: tasks_waiting_overlapped

Number of tasks waiting on overlapped I/O operations.

.. attribute:: completion_key_monitors

Number of completion key monitors.

.. attribute:: backend

This attribute holds a string value that corresponds to the statistics type.
This class has ``backend == "windows"``.
Use ``backend`` attribute to distinguish statistics types at runtime.
"""

tasks_waiting_read: int
tasks_waiting_write: int
tasks_waiting_overlapped: int
Expand Down
8 changes: 7 additions & 1 deletion src/trio/_core/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@


@final
class _NoValue: ...
class _NoValue:
"""Sentinel class object, used as the "undefined" variable value.

A :class:`~trio.lowlevel.RunVar` variable has this "stub" value
until the variable is assigned an actual value.
It is distinct from ``None``, which is a legitimate value a variable can hold.
"""


@final
Expand Down
11 changes: 11 additions & 0 deletions src/trio/_core/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,17 @@ def __del__(self) -> None:
@final
@attrs.define(eq=False, repr=False)
class Task(metaclass=NoPublicConstructor): # type: ignore[explicit-any]
"""A ``Task`` object represents a concurrent "thread" of execution.

See the :class:`~trio.lowlevel.Task` entry in Trio's lowlevel module docs for a detailed description.
Trio's task primitive wraps a coroutine (`types.CoroutineType`),
adding more functionality for stopping and resuming tasks,
for scheduling and canceling tasks,
for associating a ``Task`` with a ``Runner`` and context variables.
A ``Task`` can belong to a :class:`~trio.Nursery` and can spawn
its own child nurseries. See :class:`~trio.Nursery` docs for more information.
"""

_parent_nursery: Nursery | None
coro: types.CoroutineType[Any, Outcome[object], Any] # type: ignore[explicit-any]
_runner: Runner
Expand Down
5 changes: 4 additions & 1 deletion src/trio/_file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ class _HasErrors(Protocol):
def errors(self) -> str | None: ...

class _HasFileNo(Protocol):
def fileno(self) -> int: ...
"""Represents any file-like object that has a file descriptor."""

def fileno(self) -> int:
"""Return the file descriptor."""

class _HasIsATTY(Protocol):
def isatty(self) -> bool: ...
Expand Down
5 changes: 5 additions & 0 deletions src/trio/_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ async def _resolve_address_nocp(


class SocketType:
"""Trio's version of the standard library's :class:`socket.socket`.

Encompasses some Trio-specific platform handling logic.
"""

def __init__(self) -> None:
# make sure this __init__ works with multiple inheritance
super().__init__()
Expand Down
4 changes: 3 additions & 1 deletion src/trio/_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def pidfd_open(fd: int, flags: int) -> int:
class HasFileno(Protocol):
"""Represents any file-like object that has a file descriptor."""

def fileno(self) -> int: ...
def fileno(self) -> int:
"""Return the file descriptor."""
...


@final
Expand Down
19 changes: 17 additions & 2 deletions src/trio/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,27 @@ def __bool__(self) -> Literal[True]:
class _HasAcquireRelease(Protocol):
"""Only classes with acquire() and release() can use the mixin's implementations."""

async def acquire(self) -> object: ...
async def acquire(self) -> object:
"""Acquire the resource (lock).

def release(self) -> object: ...
See docs for :class:`~trio.Lock` and :class:`~trio.StrictFIFOLock` for usage details.
"""

def release(self) -> object:
"""Release the resource (unlock).

See docs for :class:`~trio.Lock` and :class:`~trio.StrictFIFOLock` for usage details.
"""


class AsyncContextManagerMixin:
"""An async context manager base class.

Should be used with the ``_HasAcquireRelease`` Protocol.
Calls ``await self.acquire()`` on entry and ``self.release()`` on exit,
adding :exc:`KeyboardInterrupt` protection support.
"""

@enable_ki_protection
async def __aenter__(self: _HasAcquireRelease) -> None:
await self.acquire()
Expand Down
24 changes: 3 additions & 21 deletions src/trio/_tests/_check_type_completeness.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
{
"Darwin": [
"No docstring found for function \"trio._unix_pipes.FdStream.close\"",
"No docstring found for function \"trio._unix_pipes.FdStream.fileno\""
],
"Linux": [
"No docstring found for class \"trio._core._io_epoll._EpollStatistics\"",
"No docstring found for function \"trio._unix_pipes.FdStream.close\"",
"No docstring found for function \"trio._unix_pipes.FdStream.fileno\""
],
"Darwin": [],
"Linux": [],
"Windows": [],
"all": [
"No docstring found for class \"trio._core._run.Task\"",
"No docstring found for class \"trio._socket.SocketType\"",
"No docstring found for function \"trio._subprocess.HasFileno.fileno\"",
"No docstring found for class \"trio._sync.AsyncContextManagerMixin\"",
"No docstring found for function \"trio._sync._HasAcquireRelease.acquire\"",
"No docstring found for function \"trio._sync._HasAcquireRelease.release\"",
"No docstring found for class \"trio._sync._LockImpl\"",
"No docstring found for class \"trio._core._local._NoValue\"",
"No docstring found for class \"trio.lowlevel.Task\"",
"No docstring found for class \"trio.socket.SocketType\""
]
"all": []
}
14 changes: 0 additions & 14 deletions src/trio/_tests/check_type_completeness.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,16 @@ def has_docstring_at_runtime(name: str) -> bool:
# on separate platforms. It might also be a decent idea to work the other way around,
# a la test_static_tool_sees_class_members
# darwin
"trio.lowlevel.current_kqueue",
"trio.lowlevel.monitor_kevent",
"trio.lowlevel.wait_kevent",
"trio._core._io_kqueue._KqueueStatistics",
# windows
"trio._socket.SocketType.share",
"trio._core._io_windows._WindowsStatistics",
"trio._core._windows_cffi.Handle",
"trio.lowlevel.current_iocp",
"trio.lowlevel.monitor_completion_key",
"trio.lowlevel.readinto_overlapped",
"trio.lowlevel.register_with_iocp",
"trio.lowlevel.wait_overlapped",
"trio.lowlevel.write_overlapped",
"trio.lowlevel.WaitForSingleObject",
"trio.socket.fromshare",
# linux
# this test will fail on linux, but I don't develop on linux. So the next
# person to do so is very welcome to open a pull request and populate with
# objects
# TODO: these are erroring on all platforms, why?
"trio._highlevel_generic.StapledStream.send_stream",
"trio._highlevel_generic.StapledStream.receive_stream",
"trio._ssl.SSLStream.transport_stream",
"trio._file_io._HasFileNo",
"trio._file_io._HasFileNo.fileno",
):
Expand Down
12 changes: 12 additions & 0 deletions src/trio/_unix_pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,23 @@ async def receive_some(self, max_bytes: int | None = None) -> bytes:
return data

def close(self) -> None:
"""Close the stream and close file descriptor it's wrapping.

See the class docstring for details.
"""
self._fd_holder.close()

async def aclose(self) -> None:
"""Close the stream synchronously, then execute a checkpoint.

See the class docstring for details.
"""
self.close()
await trio.lowlevel.checkpoint()

def fileno(self) -> int:
"""Return the file descriptor this `FdStream` is wrapping.

See the class docstring for details.
"""
return self._fd_holder.fd
Loading