Install & Compatibility
Where this runs
tested against v1.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 28.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 3.4s · import 0.000s · 28MB
27MB installed
● package 27MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ArgParser
✓ from argdantic import ArgParser
✗ from argdantic import Arqdantic
ArgField
✓ from argdantic import ArgField
convert
✓ from argdantic import convert
This quickstart demonstrates how to define a simple command-line application using `argdantic`. It showcases creating an `Argdantic` instance, defining a command with type-hinted arguments and Pydantic's `Field` for help text, and running the application.
from argdantic import Arqdantic
from pydantic import Field
import sys
# Instantiate the Arqdantic application
app = Arqdantic()
# Define a command using a decorator
@app.command()
def greet(
name: str = Field('World', help='The name to greet.'),
count: int = Field(1, help='Number of times to greet.')
):
"""Greets the given name multiple times."""
for _ in range(count):
print(f"Hello, {name}!")
if __name__ == "__main__":
# Example of how to run from the CLI:
# python your_script.py greet --name Alice --count 3
# For testing within the script, you can temporarily modify sys.argv:
# sys.argv = ['your_script.py', 'greet', '--name', 'Alice', '--count', '3']
app() # This parses sys.argv and executes the command
argdantic --version
Debug
Known issues
breakingMajor API overhaul in version 1.0.0 changed the way commands are defined and executed.fixMigrate from `argdantic.parse()` with a Pydantic model to using the `Argdantic` class instance with `@app.command()` decorators and calling `app()` or `app.run()`.
affects: <1.0.0 to >=1.0.0
gotchaForgetting to call `app()` or `app.run()` at the end of your script will result in the CLI application not parsing arguments or executing commands.fixEnsure `if __name__ == '__main__': app()` is present in your main script file.
affects: All versions >=1.0.0
gotchaDefault values for arguments without `Field` metadata will be inferred from the type annotation, but `help` messages and custom descriptions will be missing.fixAlways use `pydantic.Field` for CLI arguments to provide explicit default values, help messages, and other metadata (e.g., `..., help='Description'`).
affects: All versions
Upgrade
Version history
1.3.3latest on PyPI · released Jan 10, 2025
Audit
Dependencies
pydanticrequiredUsed for defining argument models and data validation.