--- id: pydantic-function-models version: "0.1.12" license: MIT license_treatment: permissive maintenance: active --- # pydantic-function-models — Migrating v1 Pydantic ValidatedFunction to v2. License: permissive · Maintenance: active · Downloads: 589.7K/mo ## 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 above — 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 pip install pydantic-function-models uv add pydantic-function-models poetry add pydantic-function-models ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 589.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pydantic function argument validation, validate function signatures pydantic, pydantic v1 validatedfunction migration, function parameter type checking, pydantic function wrapper, runtime argument validation, function signature modeling, pydantic-v1-migration, type-validation, function-wrapping [View on SkillFed](https://skillfed.io/packages/pydantic-function-models) · [View on PyPI](https://pypi.org/project/pydantic-function-models/)