Skip to main content

arcparse

Declare program arguments in a type-safe way.

This project builds on top of argparse by adding type-safety and allowing a more expressive argument parser definition.

Example usage

from arcparse import arcparser, flag, positional
from pathlib import Path

@arcparser
class Args:
    path: Path = positional()
    recurse: bool = flag("-r")
    item_limit: int = 100
    output_path: Path | None

args = Args.parse()
print(f"Scanning {args.path}...")
...
Help output of this parser
usage: program.py [-h] [-r] [--item-limit ITEM_LIMIT] [--output-path OUTPUT_PATH] path

positional arguments:
path

options:
-h, --help            show this help message and exit
-r, --recurse
--item-limit ITEM_LIMIT
--output-path OUTPUT_PATH

For more examples see Examples.

Installation

# Using pip
$ pip install arcparse

Features

Credits

This project was inspired by swansonk14/typed-argument-parser.

Known issues

Annotations

from __future__ import annotations makes all annotations strings at runtime. This library relies on class variable annotations's types being actual types. inspect.get_annotations(obj, eval_str=True) is used to evaluate string annotations to types in order to assign converters. If an argument is annotated with a non-builtin type which is defined outside of the argument-defining class body the type can't be found which results in NameErrors. This is avoidable either by only using custom types which have been defined in the argument-defining class body (which is restrictive), or alternatively by not using the annotations import which should not be necessary from python 3.14 forward thanks to PEP 649.

Metadata

Release files for arcparse 1.3.2

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

Source distribution (sdist)

Source distribution for arcparse 1.3.2
File Size Uploaded
arcparse-1.3.2.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arcparse 1.3.2
File Interpreter ABI Platform
arcparse-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / arcparse-1.3.2.tar.gz

Download URL arcparse-1.3.2.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e4a692d822b05459ffb5056f1509e0cc7028d40e3a11a95b10df46bc17e098bf
BLAKE2b-256 checksum
How to use checksums
4217340a3ceea10be16a1683850ad365d19a9482613732b1cb6a103ede25dc63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.13.12 Darwin/25.3.0

Release files / arcparse-1.3.2-py3-none-any.whl

Download URL arcparse-1.3.2-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
206247fd1d19e19c9829a306343e2ae38c409a3e38313ecaaa9d27be6881dd99
BLAKE2b-256 checksum
How to use checksums
05f2411dba4ecde12599c9040ff97c59b2b93e040b798e1b978bde1e2b884b86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.13.12 Darwin/25.3.0

Release history Release notifications | RSS feed

This release

1.3.2 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.6.16

2 release files

0.6.15

2 release files

0.6.13

2 release files

0.6.12

2 release files

0.6.11

2 release files

0.6.10

2 release files

0.6.9

2 release files

0.6.8

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

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