Describe the bug
pydantic fields with _outertype (Eg. typing.List, typing.Set etc) are populated with the wrong type in documentation. The documentation shows only the inner type. (See example)
To Reproduce
from typing import List, Union
from pydantic import BaseModel, Field
class MyModel(BaseModel):
"""
MyModel
"""
attr_bug: List[str] = Field(..., description="This is a mock attribute that is buggy")
attr_perfect: Union[List[str], List[int]] = Field(description="This is a mock attribute that is perfect")
The type information of the attr_bug shows up as str and not List[str] (which is expected)
The type information of the attr_perfect shows up as Union[List[str], List[int]] as expected
Expected behavior
Explained above below the code example.
Screenshots
Attaching a screenshot of the documentation produced by mkdocstrings with the above example code
System (please complete the following information):
pytkdocs version : 0.10.1
mkdocstrings version : 0.14.0
Python version: 3.6.1 (I know I should update!!)
OS: macOS
Additional context
According to my quick run through the code of pytkdocs and pydantic, the reason is most probably because of the below line.
Instead of the above line, it should have been prop.outer_type_ (that is provided by pydantic here).
Debug code
print(MyModel.__dict__["__fields__"]["attr_bug"].type_)
# prints <class 'str'>
print(MyModel.__dict__["__fields__"]["attr_bug"].outer_type_)
# prints typing.List[str]
Lastly, thank you very much for creating mkdocstrings (and pytkdocs)
Describe the bug pydantic fields with _outertype (Eg.
typing.List
,typing.Set
etc) are populated with the wrong type in documentation. The documentation shows only the inner type. (See example)To Reproduce
attr_bug
shows up asstr
and notList[str]
(which is expected)attr_perfect
shows up asUnion[List[str], List[int]]
as expectedExpected behavior
Explained above below the code example.
Screenshots Attaching a screenshot of the documentation produced by mkdocstrings with the above example code
System (please complete the following information):
pytkdocs
version : 0.10.1mkdocstrings
version : 0.14.0Additional context
According to my quick run through the code of
pytkdocs
andpydantic
, the reason is most probably because of the below line.https://github.com/mkdocstrings/pytkdocs/blob/bf04764f1608970643932329c9f6c8c63a0c5632/src/pytkdocs/loader.py#L682
Instead of the above line, it should have been
prop.outer_type_
(that is provided by pydantic here).Debug code
Lastly, thank you very much for creating mkdocstrings (and pytkdocs)