Skip to content

Commit

Permalink
✨ pydantic config model support
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Feb 14, 2025
1 parent 002cc12 commit d921f71
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 3 deletions.
23 changes: 23 additions & 0 deletions arclet/entari/builtins/pyd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import Any, TypeVar

from arclet.entari.config import config_validator_register
from arclet.entari.plugin import metadata, declare_static
from pydantic import BaseModel, TypeAdapter

declare_static()
metadata(
"pydantic",
author=["RF-Tar-Railt <rf_tar_railt@qq.com>"],
description="Pydantic Config Model support for entari",
)


TB = TypeVar("TB", bound=BaseModel)


@config_validator_register(BaseModel)
def _pydantic_validate(data: dict[str, Any], base: type[TB]) -> TB:
return TypeAdapter(base).validate_python(data)


__all__ = ["BaseModel"]
135 changes: 132 additions & 3 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ full = [
dotenv = [
"python-dotenv>=1.0.1",
]
pydantic = [
"pydantic>=2.10.6",
]

[project.scripts]
entari = "arclet.entari.__main__:main"
Expand Down

0 comments on commit d921f71

Please sign in to comment.