Skip to main content

Strongly typed, zero-effort CLIs

Project description

dcargs

build mypy lint codecov PyPI Python Version

dcargs is a library for typed CLI interfaces and configuration objects.

pip install dcargs

Our core interface generates argument parsers from type-annotated callables. In the simplest case, this can be used as a drop-in replacement for argparse:

with argparse with dcargs
import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
    "--a",
    type=int,
    required=True,
)
parser.add_argument(
    "--b",
    type=int,
    default=3,
)
args = parser.parse_args()

print(args.a + args.b)
import dcargs

def main(a: int, b: int = 3) -> None:
    print(a + b)

dcargs.cli(main)

The broader goal is to enable replacing configuration frameworks like hydra, gin-config, and ml_collections with hierarchical structures built using standard Python dataclasses and type annotations.

For a full list of features and usage examples, see our documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcargs-0.1.9.tar.gz (28.0 kB view hashes)

Uploaded Source

Built Distribution

dcargs-0.1.9-py3-none-any.whl (32.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page