Skip to content

Commit 5df7a47

Browse files
committed
fix: Make Pydantic imports lazy
Issue-39: #39
1 parent a907923 commit 5df7a47

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ maintain = [
8282
]
8383
ci = [
8484
"duty>=1.6",
85+
"griffe>=1.10",
8586
"ruff>=0.4",
8687
"pytest>=8.2",
8788
"pytest-cov>=5.0",

src/griffe_pydantic/_internal/dynamic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
Kind,
1111
get_logger,
1212
)
13-
from pydantic.fields import FieldInfo
1413

1514
from griffe_pydantic._internal import common
1615

@@ -19,6 +18,8 @@
1918

2019
def _process_attribute(obj: Any, attr: Attribute, cls: Class, *, processed: set[str]) -> None:
2120
"""Handle Pydantic fields."""
21+
from pydantic.fields import FieldInfo # noqa: PLC0415
22+
2223
if attr.canonical_path in processed:
2324
return
2425
processed.add(attr.canonical_path)

tests/test_extension.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def test_extension(analysis: str) -> None:
6666
"package",
6767
modules={"__init__.py": code},
6868
extensions=Extensions(PydanticExtension(schema=True)),
69+
search_sys_path=analysis == "dynamic",
6970
) as package:
7071
assert package
7172

0 commit comments

Comments
 (0)