Add smarts to autodoc_utils for inherited TypedDicts.
Review Request #14480 — Created June 27, 2025 and submitted
TypedDict
inheritance is weird in a way that Sphinx can't deal with
easily.TypedDict
isn't actually a class itself, and things which
inherit from it get flattened to inherit directly fromdict
and have a
variety of annotation-only properties for the data inside. Sphinx can
find any documentation attached to those properties, but when one
inherits from another, the documentation for any properties coming from
the parent class gets lost.This change adds some custom documenter classes to detect when we have
inherited TypedDict members and to scan up the chain using
__orig_bases__
to find docs for inherited members.This requires Python 3.11+ if using
typing.TypedDict
. It works for all
versions when usingtyping_extensions.TypedDict
.
- Built the RBTools documentation with this and saw that all of our new
*Params
definitions had documentation for all members, including ones
inherited from parent classes. - Ran unit tests.
Summary | ID |
---|---|
e7869c4db5a0ffdc3b135721c9f997f5a0ac088f |
Description | From | Last Updated |
---|---|---|
Let's make autodoc_utils a literal. |
|
|
Missing the ending __ on __orig_bases__ |
![]() |
|
Should say "versions" or "an older version" here instead of just of "version" |
![]() |
|
"for" or "from"? |
|
|
This requires 3.9+. That might be fine but it'd be nice to keep this module a bit wider in terms … |
|
|
Should we use Sequence instead of list? |
|
|
We access self.object 3 times outside the loop and every iteration within the loop where there's a docstring. Let's pull … |
|
|
Should this be a Sequence? |
|
|
Missing a period. |
|
|
Missing a period. |
|
|
Can we use obj instead, so we're not stomping on object? |
|
-
-
-
-
This requires 3.9+. That might be fine but it'd be nice to keep this module a bit wider in terms of Python compatibility so we can more easily continue to build docs for older (but still recent) products and deal with any issues that come up.
Can we keep this a standard dict and move the typing into the annotation?
-
-
We access
self.object
3 times outside the loop and every iteration within the loop where there's a docstring. Let's pull it out. -
-
-