Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
9dcfd25
Support defaults from Pydantic fields
jinnovation May 1, 2025
991910c
gate specifically on pydantic
jinnovation May 2, 2025
b077891
do not include importerror block in test coverage
jinnovation May 2, 2025
19efc29
extend pragma no cover
jinnovation May 2, 2025
7a32d2b
WIP: Convert to snapshot test
jinnovation May 2, 2025
a413dd9
remove dataclass import
jinnovation May 2, 2025
25090dd
create _pydantic module
jinnovation Oct 11, 2025
bad5751
Merge remote-tracking branch 'upstream/main' into pydantic
jinnovation Oct 11, 2025
a2ab163
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 11, 2025
83f467c
fix lint
jinnovation Oct 11, 2025
5381116
fix importlib import
jinnovation Oct 11, 2025
adbe853
mark generated files
jinnovation Oct 11, 2025
10c35b8
suppress BaseModel fields
jinnovation Oct 11, 2025
3206e0f
harden
jinnovation Oct 11, 2025
9f9e5d6
update snapshot
jinnovation Oct 11, 2025
236e97d
add note
jinnovation Oct 11, 2025
b576d73
changelog
jinnovation Oct 11, 2025
db7938d
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 11, 2025
5d44d35
Merge remote-tracking branch 'upstream/main' into pydantic
jinnovation Oct 11, 2025
cdee9e5
add docs
jinnovation Oct 11, 2025
010d26b
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 11, 2025
5182cd0
Merge branch 'main' into pydantic
jinnovation Oct 11, 2025
ee2a783
undo gitattributes
jinnovation Oct 12, 2025
3f26ff7
Update pdoc/__init__.py
jinnovation Oct 12, 2025
fb31c98
render docstring
jinnovation Oct 12, 2025
9327e13
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 12, 2025
1795c40
_pydantic.skip_field
jinnovation Oct 12, 2025
9a19f6e
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 12, 2025
82d54fe
fix lint
jinnovation Oct 12, 2025
976c236
refining pydantic-installed detection logic
jinnovation Oct 12, 2025
3506b48
fix lint
jinnovation Oct 12, 2025
cd271f2
support 3.9 type checking
jinnovation Oct 12, 2025
5fd7462
expand type annotations
jinnovation Oct 12, 2025
7567fe5
cleanup
jinnovation Oct 17, 2025
8f0441c
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 17, 2025
33d9cd9
typecast
jinnovation Oct 17, 2025
84289e6
Merge remote-tracking branch 'jinnovation/pydantic' into pydantic
jinnovation Oct 17, 2025
938c762
move field exclusion to `Class._member_objects`
jinnovation Oct 17, 2025
7ef7160
rm defunct fn
jinnovation Oct 17, 2025
c2d876c
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 17, 2025
f75ff51
simplify
jinnovation Oct 17, 2025
715ab6b
Merge remote-tracking branch 'jinnovation/pydantic' into pydantic
jinnovation Oct 17, 2025
121a462
refine type annotations
jinnovation Oct 17, 2025
631921a
reuse is_pydantic_model logic
jinnovation Oct 19, 2025
c80ffaa
simplify
jinnovation Oct 19, 2025
5fe87cf
use frozenset
jinnovation Oct 19, 2025
2e3b63a
rm unused
jinnovation Oct 19, 2025
47fac11
[autofix.ci] apply automated fixes
autofix-ci[bot] Oct 19, 2025
09a881f
is_pydantic_model return False if pydantic not installed
jinnovation Oct 19, 2025
84ff322
Merge remote-tracking branch 'jinnovation/pydantic' into pydantic
jinnovation Oct 19, 2025
332a95e
simplify (ish) conditional import logic
jinnovation Oct 19, 2025
7392041
simplify field-pruning
jinnovation Oct 19, 2025
408f9a2
localize more logic to _pydantic
jinnovation Oct 19, 2025
efaafcd
import TypeGuard from typing_extensions
jinnovation Oct 19, 2025
d5b4056
simplify docstring logic
jinnovation Oct 19, 2025
d16fda6
Update pdoc/doc.py
jinnovation Oct 19, 2025
670dd71
simplify
jinnovation Oct 20, 2025
b879d38
Merge remote-tracking branch 'jinnovation/pydantic' into pydantic
jinnovation Oct 20, 2025
d2b5a20
Merge remote-tracking branch 'origin/main' into pydantic
jinnovation Oct 20, 2025
4e7b623
Update pdoc/_pydantic.py
jinnovation Oct 20, 2025
7273f92
Revert "import TypeGuard from typing_extensions"
jinnovation Oct 21, 2025
8324327
Merge remote-tracking branch 'jinnovation/pydantic' into pydantic
jinnovation Oct 21, 2025
267b995
Merge remote-tracking branch 'origin/main' into pydantic
jinnovation Oct 21, 2025
cbcc6d0
add typing.cast back in
jinnovation Oct 21, 2025
51288cd
simplify
jinnovation Oct 21, 2025
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
9 changes: 8 additions & 1 deletion pdoc/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,19 @@ def members(self) -> dict[str, Doc]:
taken_from=taken_from,
)
else:
try:
default_value = self._member_objects["__pydantic_fields__"][
name
].default
except KeyError:
default_value = obj

doc = Variable(
self.modulename,
qualname,
docstring="",
annotation=self._var_annotations.get(name, empty),
default_value=obj,
default_value=default_value,
taken_from=taken_from,
)
if self._var_docstrings.get(name):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dev-dependencies = [
"pytest-timeout>=2.3.1",
"hypothesis>=6.113.0",
"pdoc-pyo3-sample-library>=1.0.11",
"pydantic>=2.11.4",
]

[build-system]
Expand Down
28 changes: 28 additions & 0 deletions test/test_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,34 @@ class Foo(metaclass=FooMeta):
assert x.docstring == ""


@pytest.mark.parametrize(
"member, defaults",
[
(
"Foo",
{
"a": "1",
"b": "2",
},
),
(
"PydanticStyleDataclass",
{
"a": "1",
},
),
],
)
def test_with_pydantic(member, defaults):
m = Module.from_name("test.with_pydantic")
assert "Foo" in m.members

cls: Class = m.members[member]

for k, v in defaults.items():
assert cls.members[k].default_value_str == v


def test_raising_submodules():
f = here / "syntax_err" / "syntax_err.py"
f.write_bytes(b"class")
Expand Down
14 changes: 14 additions & 0 deletions test/with_pydantic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pydantic
from pydantic.dataclasses import dataclass


class Foo(pydantic.BaseModel):
a: int = pydantic.Field(default=1, description="Docstring for a")

b: int = 2
"""Docstring for b."""


@dataclass
class PydanticStyleDataclass:
a: int = 1
Loading
Loading