pydantic-function-models
Migrating v1 Pydantic ValidatedFunction to v2.
What it is and what it does
pydantic-function-models lets you wrap any Python function to enforce type validation on its arguments using Pydantic's validation engine. It builds an internal Pydantic model from the function's signature and type hints, then validates incoming arguments (positional or keyword) against that model before execution. The package was created to bridge the gap left by Pydantic v2's removal of ValidatedFunction from v1, offering a direct migration path for code that relied on that feature.
The library is designed for cases where you need to model and validate a function's full signature as a structured entity—distinct from Pydantic's validate_call decorator, which is simpler but less flexible for introspection. It includes safeguards against reserved parameter names that could conflict with internal validation logic, and raises clear Pydantic ValidationError messages when arguments don't match declared types.
Use it for:
- Migrating Pydantic v1 code that used ValidatedFunction to v2 without rewriting validation logic.
- Building CLI tools or APIs that need to validate function arguments against strict type contracts before execution.
- Introspecting and modeling function signatures as Pydantic models for serialization or schema generation.
- Enforcing type safety in plugin systems or dynamic function dispatch where arguments come from untrusted sources.
- Creating wrapper layers that log or audit function calls with validated, structured argument data.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wraps Python functions to validate their arguments against type hints using Pydantic models, providing a migration path from Pydantic v1's deprecated ValidatedFunction.
Yes, if you are migrating from Pydantic v1's ValidatedFunction or need to model and validate function signatures as structured Pydantic models. The package is actively maintained, has no known vulnerabilities, and carries a permissive MIT license. Install friction is minimal. However, if you only need basic argument validation without signature introspection, Pydantic's validate_call decorator may be simpler.
Install
pydantic-function-models on PyPI
pip
pip install pydantic-function-modelsuv
uv add pydantic-function-modelspoetry
poetry add pydantic-function-modelsInstalling pydantic-function-models
Before you install
Low friction: pure Python wheel with a single runtime dependency on pydantic. Actively maintained with a recent commit (2026-08-10) and no known vulnerabilities.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
from pydantic_function_models import ValidatedFunction
def add(a: int, b: int) -> int:
return a + b
vf = ValidatedFunction(add)
validated = vf.model.model_validate({"a": 1, "b": 2})
result = add(**validated.model_dump(exclude_unset=True))
print(result) # 3
Requires Python 3.10 or later; pydantic must be installed as the sole runtime dependency.
Verify before relying
- Whether ValidatedFunction fully replicates Pydantic v1 behavior or has known gaps for complex signatures.
- Performance characteristics when validating functions with many parameters or nested type hints.
- Compatibility with Pydantic's validate_call decorator and how the two approaches differ in practice.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pydantic |
| Maintenance | actively maintained — 120 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 589,678/month — #5,858 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pydantic_function_models-0.1.12-py3-none-any.whl
Keywords: pydantic, serialization, deserialization, parsing
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
django-pydantic-fieldProvides type-safe Pydantic model schemas for…
permissive · top 5,000 on PyPI
pydantic-compatProvides compatibility mixins and adapters to…
permissive · top 15,000 on PyPI
pydantic_corepydantic-core provides the high-performance…
permissive · top 100 on PyPI
backcallbackcall lets you define and validate callback…
permissive · top 5,000 on PyPI
drf-pydanticBridges pydantic models and Django REST…
permissive · top 15,000 on PyPI
jsonschema-pydantic-converterConverts JSON Schema definitions to Pydantic v2…
permissive · top 15,000 on PyPI
python-flirtParse, compile, and match FLIRT signatures…
permissive · top 15,000 on PyPI
Flask-PydanticAdds Pydantic model validation to Flask route…
permissive · top 15,000 on PyPI
pydantic-xmlPydantic-xml adds XML serialization and…
permissive · top 5,000 on PyPI