Skip to main content

an easy-to-integrate typed argument parser

Project description

Argparse Type Helper

A lightweight helper that lets you leverage type hints with argparse.

Features

  • Class-based schema Bundle all your arguments in a single @targs-decorated class.
  • Identical API Each field uses the same parameters as argparse.add_argument (help, action, nargs, etc.).
  • Automatic registration One call to register_targs(parser, YourArgs) wires up all arguments on your ArgumentParser.
  • Typed extraction After parse_args(), call extract_targs() to get a fully-typed instance of your class.
  • Hybrid usage Mix native parser.add_argument(...) calls with class-based definitions in the same parser.
  • Docstring support Use docstrings to automatically generate help text for your arguments.

Installation

pip install argparse-type-helper

Usage

See example.py.

Why not typed-argparse?

typed-argparse is a great library, but it replaces the familiar argparse.add_argument API with its own argument-definition interface, which can be a hurdle when integrating into an existing codebase.

argparse-type-helper, by contrast, is a simple helper that allows you to use type hints with argparse with minimal learning curve. It uses the same argparse API you’re already familiar with, and you can even mix native argparse usage with class-based definitions in the same parser.

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

argparse_type_helper-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argparse_type_helper-0.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file argparse_type_helper-0.1.0.tar.gz.

File metadata

  • Download URL: argparse_type_helper-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for argparse_type_helper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cafb0e6c82f6484ed0183d028006b3df6a6bf565aa54c90cc289cf143706c871
MD5 7d1f96722ef1605460ca7c28cce09110
BLAKE2b-256 874647424fc25a2940dfc7ccee49f2021fec95852b20efda7123ed5a9c1e73c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for argparse_type_helper-0.1.0.tar.gz:

Publisher: publish.yml on lljbash/argparse-type-helper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file argparse_type_helper-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for argparse_type_helper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a16f1e65a498efcd50cedb282cfad6d95dd5441392dc86bf4abd6297462dba11
MD5 35f5f1cff65b7122815f3fbc028f2280
BLAKE2b-256 0b0765c836fb981974095fd4a126cc53da39cb5ffceb1f074120a85e9252fc7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for argparse_type_helper-0.1.0-py3-none-any.whl:

Publisher: publish.yml on lljbash/argparse-type-helper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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