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
- Positional, Option and Flag arguments
- Name overriding
- Multiple values per argument
- Type conversions
- Mutually exclusive groups
- Subparsers
- Parser inheritance (with overriding)
- Presence validation
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arcparse-1.3.2.tar.gz | 12.1 kB | Without provenance | Details for arcparse-1.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arcparse-1.3.2-py3-none-any.whl | Python 3 | none | any | Details for arcparse-1.3.2-py3-none-any.whl |
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
|
Security for arcparse 1.3.2
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.