You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Libdoc: TypedDicts used as types with other TypedDicts are not automatically documented #5844
Libdoc documents a type under "Data types" only when it appears in a keyword's argument or return type. It does not look into the fields of a TypedDict. A TypedDict that only appears as a field of another TypedDict is therefore never documented and cannot be linked.
Example from Browser library. Wait For Response returns a CapturedResponse:
classHeaderEntry(TypedDict):
"""One HTTP header, as listed in ``headersArray``."""name: strvalue: strclassServerAddress(TypedDict):
ipAddress: strport: intclassCapturedResponse(TypedDict):
status: intheadersArray: list[HeaderEntry]
serverAddr: ServerAddress|Nonerequest: CapturedRequest
...
CapturedResponse shows up under "Data types". HeaderEntry and ServerAddress do not, even though users need their structure. Two more consequences:
In the "Dictionary structure" of CapturedResponse, the field types are plain text without links. The names are also fully qualified: <list[Browser.utils.data_types.HeaderEntry]>.
In docstrings, `HeaderEntry` does not become a link, because the type is unknown to Libdoc.
Library authors currently have to repeat the structure of every nested type inline in the docstring of the outer type. Browser does this today.
See in Browser v21.0.0 Keyword Docs in New Context the argument recordVideo as one example.
And see Libdoc PoC with Browser and the New Context keyword with recordVideo argument or the Return Values of Wait For Request and Wait For Response to see how it could work.
Proposal
TypeDocBuilder._yield_infos (robotbuilder.py) also recurses into TypedDictInfo.annotations, with a guard against recursive TypedDicts. Nested TypedDicts, Enums and other types then get documented like argument types, and their usages list the keyword.
TypedDictItem keeps its TypeInfo and serializes it as typeInfo (same shape as an argument's type: name, typedoc, nested, union, alias). The HTML template renders it with the existing renderTypeInfo helper. Field types then become clickable links. Navigation
between type dialogs, including the back link, already works.
type stays for backwards compatibility. It uses str(TypeInfo), which gives list[HeaderEntry] instead of the module path.
I'm happy to open a PR if this direction is acceptable.
While working on this I noticed that a recursive TypedDict already fails is 7.5 and earlier, independent of Libdoc.
A library using it cannot even be imported.
With Python 3.9, execution does not crash, but the test fails with RecursionError: maximum recursion depth exceeded while calling a Python object.
Tested with RF 7.5.1 on Python 3.12 and 3.9, and with current master.
The recursion happens in TypedDictInfo.__init__. It creates a TypeInfo for every field, so Node -> list[Node] -> Node -> ... never ends:
File ".../robot/running/arguments/typeinfo.py", line 251, in from_type_hint
return TypedDictInfo(hint.__name__, hint, alias=alias)
File ".../robot/running/arguments/typeinfo.py", line 509, in __init__
name: TypeInfo.from_type_hint(hint) for name, hint in type_hints.items()
[...]
RecursionError: maximum recursion depth exceeded
Recursive type aliases are already handled (RecursiveAlias), but recursive TypedDicts are not.
This can also be fixed in TypedDictInfo.
While fixing the recursion, I found an existing problem in RecursiveConverter. It was added with recursive type alias support in RF 7.5. When a nested value is invalid, the error message wraps an inner "Argument ... cannot be converted to ..." message at every level of recursion.
Reproduction (Python 3.12+):
fromrobot.runningimportTypeInfo
type Nested=list[Nested]
TypeInfo.from_type_hint(Nested).convert("[[1]]")
Current result:
ValueError: Argument '[[1]]' cannot be converted to Nested: Item '0' got value '[1]' (list) that cannot be converted to Nested: Argument '[1]' (list) cannot be converted to list[Nested]: Item '0' got value '1' (integer) that cannot be converted to Nested: Argument '1' (integer) cannot
be converted to list[Nested].
RecursiveConverter calls the resolved converter without name and kind. The inner converter therefore produces a complete "Argument ..." message, and the outer converter wraps it a second time. Most recursive aliases are unions, such as JSON. Union converters do not show the
details of inner errors, which is probably why this has not come up so far. With recursive TypedDicts it would occur on every invalid nested value.
My fix makes RecursiveConverter pass name and kind to the resolved converter and keep the alias name. The message has no duplicate parts, and nested levels use the same type name as the top level:
ValueError: Argument '[[1]]' cannot be converted to Nested: Item '0' got value '[1]' (list) that cannot be converted to Nested: Item '0' got value '1' (integer) that cannot be converted to Nested.
Plenty of related issues that all look somewhat severe. If I got it right, there are no regressions, though. Nested TypeDicts also apparently work even though Libdoc doesn't handle them too well. The problem with recursive TypedDicts should get its own issue.
Fixing everything properly is a somewhat big task require plenty of changes. I thus believe it would be better to fix this in RF 7.6 than in RF 7.5.2.
Let's concentrate on the documentation issue with nested TypedDicts in this issue. Can you @Snooz82 submit a separate issue about the crash with recursive TypedDicts or should I do that? I believe both of these can wait for RF 7.6.
changed the title [-]Libdoc: document TypedDicts nested in TypedDict items and link item types[/-][+]Libdoc: TypedDicts used as types with other TypedDicts are not automatically documented[/+]on Nov 18, 2026
Activity
Snooz82 commentedon Nov 2, 2026
Hi @pekkaklarck,
While working on this I noticed that a recursive
TypedDictalready fails is 7.5 and earlier, independent of Libdoc.A library using it cannot even be imported.
RecursiveTypedDict.py:test.robot:Libdoc:
Execution:
With Python 3.9, execution does not crash, but the test fails with
RecursionError: maximum recursion depth exceeded while calling a Python object.Tested with RF 7.5.1 on Python 3.12 and 3.9, and with current
master.The recursion happens in
TypedDictInfo.__init__. It creates aTypeInfofor every field, soNode->list[Node]->Node-> ... never ends:Recursive type aliases are already handled (
RecursiveAlias), but recursiveTypedDicts are not.This can also be fixed in
TypedDictInfo.Snooz82 commentedon Nov 2, 2026
While fixing the recursion, I found an existing problem in
RecursiveConverter. It was added with recursive type alias support in RF 7.5. When a nested value is invalid, the error message wraps an inner "Argument ... cannot be converted to ..." message at every level of recursion.Reproduction (Python 3.12+):
Current result:
RecursiveConvertercalls the resolved converter withoutnameandkind. The inner converter therefore produces a complete "Argument ..." message, and the outer converter wraps it a second time. Most recursive aliases are unions, such asJSON. Union converters do not show thedetails of inner errors, which is probably why this has not come up so far. With recursive
TypedDicts it would occur on every invalid nested value.My fix makes
RecursiveConverterpassnameandkindto the resolved converter and keep the alias name. The message has no duplicate parts, and nested levels use the same type name as the top level:pekkaklarck commentedon Nov 3, 2026
Plenty of related issues that all look somewhat severe. If I got it right, there are no regressions, though. Nested TypeDicts also apparently work even though Libdoc doesn't handle them too well. The problem with recursive TypedDicts should get its own issue.
Fixing everything properly is a somewhat big task require plenty of changes. I thus believe it would be better to fix this in RF 7.6 than in RF 7.5.2.
pekkaklarck commentedon Nov 18, 2026
Let's concentrate on the documentation issue with nested TypedDicts in this issue. Can you @Snooz82 submit a separate issue about the crash with recursive TypedDicts or should I do that? I believe both of these can wait for RF 7.6.
[-]Libdoc: document TypedDicts nested in TypedDict items and link item types[/-][+]Libdoc: TypedDicts used as types with other TypedDicts are not automatically documented[/+]