skillfed

pydantic-argparse

Typed Argument Parsing with Pydantic

pydantic-argparse v0.10.0 1.2M downloads/30d#4,292 on PyPI138
Permissive license MIT Active released

What it is and what it does

Pydantic Argparse bridges Pydantic models and command-line argument parsing by automatically generating argument parsers from your model definitions. Instead of manually writing argparse code with separate type hints and validation, you define a Pydantic BaseModel with fields and their descriptions, and the package generates a fully-featured CLI parser that enforces types, provides help text, and handles aliases—all derived from your model schema.

The package is useful when you want CLI tools to have the same validation and type safety as your application code. It reduces boilerplate by eliminating the need to duplicate type information between your Pydantic models and argparse setup, and it automatically generates help output that matches your field descriptions.

Use it for:

  • Build CLI tools where argument types and validation rules are already defined in Pydantic models
  • Generate help text and argument documentation automatically from model field descriptions
  • Enforce type validation on command-line inputs without manual argparse configuration
  • Create tools with required and optional arguments, flags, and aliases all specified in a single model
  • Reduce boilerplate when multiple CLI scripts share the same argument structure

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Generates command-line argument parsers from Pydantic models, automatically handling type validation, help text, and argument aliases based on your model definition.

Yes. The package has low install friction, active maintenance, no known vulnerabilities, and a permissive MIT license. It solves a genuine problem—eliminating duplication between Pydantic models and argparse setup—and is well-suited for projects already using Pydantic. Verify Pydantic v2 compatibility if your project uses v2.

Install

pydantic-argparse on PyPI

pip

pip install pydantic-argparse

uv

uv add pydantic-argparse

poetry

poetry add pydantic-argparse

Installing pydantic-argparse

Before you install

Low install friction with a single runtime dependency on pydantic. The package is actively maintained with recent commits and has been in development since 2021, supporting current Python versions from 3.8 onwards.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects with minimal obligations.

Quickstart

pip install pydantic-argparse

import pydantic.v1 as pydantic
import pydantic_argparse

class Arguments(pydantic.BaseModel):
    name: str = pydantic.Field(description="Your name")

parser = pydantic_argparse.ArgumentParser(model=Arguments)
args = parser.parse_typed_args()
print(args)

Requires Python 3.8+ and is compatible with the Pydantic v1 API.

Verify before relying

  • Compatibility with Pydantic v2 (description mentions v1 API compatibility but v2 support status unclear)
  • Performance characteristics with large or deeply nested model hierarchies

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — pydantic
Maintenance actively maintained — 551 days since the last release
Last repo commit
First released
Downloads 1,153,548/month — #4,292 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pydantic_argparse-0.10.0-py3-none-any.whl

Keywords: argparse, pydantic, python, typed, validation

Development Status :: 4 - BetaFramework :: PydanticIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

pydantic argparse integrationtyped command line argumentscli parser from pydantic modelargument parsing with validationpydantic-based cli toolautomatic help text generationtyped argument validation
cli-builderpydantic-integration

More Python Modules packages