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
I cannot get annotations to work with inherited TypedDics.
Steps to reproduce the behavior:
Consider the following TypedDicts in api.py
classGeneralApiParams(TypedDict):
start_time: NotRequired[str]
"""The start time of the measurement in ISO-8601 format."""end_time: NotRequired[str]
"""The end time of the measurement in ISO-8601 format."""measurement_id: NotRequired[int]
"""The measurement ID."""client_uuid: NotRequired[str]
"""The client UUID."""tags: NotRequired[List[str]]
"""The tags of the client."""classMeasurementsApiParams(GeneralApiParams):
type: NotRequired[
Literal[
"VideoMeasurement",
"WebMeasurement",
"SpeedtestMeasurement",
"NetworkMeasurement",
]
]
"""The type of the measurement."""
➜ pdoc -d google -o docs ./measurement_api
Warn: Cannot determine where measurement_api.MeasurementsApiParams.start_time is taken from, assuming current file. (.../lib/python3.11/site-packages/pdoc/doc.py:647)
Warn: Cannot determine where measurement_api.MeasurementsApiParams.end_time is taken from, assuming current file. (.../lib/python3.11/site-packages/pdoc/doc.py:647)
Warn: Cannot determine where measurement_api.MeasurementsApiParams.measurement_id is taken from, assuming current file. (.../lib/python3.11/site-packages/pdoc/doc.py:647)
Warn: Cannot determine where measurement_api.MeasurementsApiParams.client_uuid is taken from, assuming current file. (.../lib/python3.11/site-packages/pdoc/doc.py:647)
Warn: Cannot determine where measurement_api.MeasurementsApiParams.tags is taken from, assuming current file. (.../lib/python3.11/site-packages/pdoc/doc.py:647)
The resulting documentation shows:
So it shows as inherting from a builtin dict, which it should not, because it inherits from the other TypedDict.
Thanks for the nice report. This is a relatively fundamental problem because TypedDict botches its __mro__, which means we normally cannot determine the base class via dynamic analysis. @krassowski came up with a nice workaround in sphinx-doc/sphinx#9290, which I've adapted for pdoc. If you add TypedDict as a second base class for MeasurementsApiParams, things should now work as expected once #505 is in. It would be nice if we wouldn't have to do this, but that requires an upstream fix in CPython. :)
Problem Description
I cannot get annotations to work with inherited TypedDics.
Steps to reproduce the behavior:
Consider the following TypedDicts in
api.py
Which I import in
__init__.py
like so:Running pdoc gets me:
The resulting documentation shows:
So it shows as inherting from a builtin dict, which it should not, because it inherits from the other TypedDict.
System Information
The text was updated successfully, but these errors were encountered: