argparse-dataclass simplifies creating command-line interfaces by automatically generating `argparse` arguments from Python dataclasses. It uses type hints for argument type inference and supports features like default values, help messages, and argument groups. The current version is 2.0.0, and it generally follows an as-needed release cadence for bug fixes and feature enhancements.
pip install argparse-dataclassVerified import paths — ran on the pinned version, not inferred.
Define your CLI arguments using a dataclass, then pass the dataclass type to ArgumentParser to automatically generate and parse arguments. This example demonstrates basic type inference and default values.
Change `parser = ArgumentParser(Config())` to `parser = ArgumentParser(Config)`.
Update custom dataclasses to use `_argument_settings` instead of `argument_settings` for field-specific argument configuration.
Always provide explicit and correct type hints for all dataclass fields intended to become CLI arguments. For complex types, ensure they are supported or define custom parsers.
To get a simple store_true/store_false flag, configure the field using `_argument_settings(action='store_true')` or `_argument_settings(action='store_false')` explicitly, or set `boolean_flags=False` when initializing `ArgumentParser`.
Install the package using pip: 'pip install argparse-dataclass'.
Use the correct import: 'from dataclasses import dataclass'.
Ensure all required command-line arguments are provided and correctly parsed.
Use the correct import: 'from argparse import ArgumentParser'.
Ensure that the provided argument is a valid integer.
No dependency data recorded yet.