Skip to main content

PyPI version Build Status codecov Code style: black mypy license



💡 write type-safe and elegant CLIs with a clear separation of concerns.

Features

  • Argument parsing based on type annotation (including runtime validation).
  • Support for many common types.
  • Clear separation of concern between argument parsing and business logic.
  • Support for super-low-latency shell auto-completions.
  • Great for writing sub-command CLIs.
  • Very lightweight.
  • No dependencies.
  • Fully typed itself, no extra type stubs required.
  • Offers both a high-level and a low-level API. The high-level API generally requires less code to write, is fully based on type annotations, and is the preferred way for writing new CLIs. The low-level API is mainly a low-effort migration path for incorporating type-safety into existing CLIs based on argparse.

Install

$ pip install typed-argparse

The only requirement is a modern Python (3.8+).

Basic Usage

import typed_argparse as tap


# 1. Argument definition
class Args(tap.TypedArgs):
    my_arg: str = tap.arg(help="some help")
    number_a: int = tap.arg(default=42, help="some help")
    number_b: Optional[int] = tap.arg(help="some help")
    verbose: bool = tap.arg(help="some help")
    names: List[str] = tap.arg(help="some help")


# 2. Business logic
def runner(args: Args):
    print(f"Running my app with args:\n{args}")


# 3. Bind argument definition + business logic & run
def main() -> None:
    tap.Parser(Args).bind(runner).run()

Documentation

See full documentation.

Changes

See change log.

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for typed-argparse 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typed-argparse 0.3.1
File Size Uploaded Provenance Actions
typed-argparse-0.3.1.tar.gz 18.4 kB Without provenance Details for typed-argparse-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for typed-argparse 0.3.1
File Interpreter ABI Platform Actions
typed_argparse-0.3.1-py3-none-any.whl Python 3 none any Details for typed_argparse-0.3.1-py3-none-any.whl

Total release size: 38.1 kB

Release files / typed-argparse-0.3.1.tar.gz

Download URL typed-argparse-0.3.1.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3aac61caa50206e080d09a00c3fe552bc4e642739beaef89f5f8c1131b5d5afe
BLAKE2b-256 checksum
How to use checksums
18742608ef98de41cd82743be47185048db93b4ff1bc59714666145de4376a1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / typed_argparse-0.3.1-py3-none-any.whl

Download URL typed_argparse-0.3.1-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1fbbc3c6adde19aa04edafebd8a7efccab4ddd403d03ec68172cc20b237bbaa7
BLAKE2b-256 checksum
How to use checksums
53862217b32ee0f421ebf57df7ff898638eedfe2288aa6710dba2bca0607b689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for typed-argparse 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page