Skip to main content

arglite

PyPI version Documentation Status

A lightweight, explicit argument parsing library for Python programs.

I made this for a teaching machine project I'm working on (I needed a custom argument parser for reasons), and I'm always too impatient to use argparse.

Quick start

import arglite

arglite.parser.require("name", type=str)
arglite.parser.optional("count", default=1, type=int)
arglite.parser.flag("verbose")

def main():
    print(arglite.parser.name)
    print(arglite.parser.count)
    print(arglite.parser.verbose)

if __name__ == "__main__":
    main()
python main.py --name Yo --count 5 --verbose

YAML configuration

You can also declare flags in a .arglite.yaml file in the working directory. arglite loads it automatically, or you can point to a different file with parser.load().

flags:
  name:
    help: "The user name"
    type: str
    required: true

  count:
    help: "Number of items"
    type: int
    default: 1

  verbose:
    help: "Enable verbose output"
    action: store_true
import arglite

print(arglite.parser.name)
print(arglite.parser.count)
print(arglite.parser.verbose)

Python declarations override YAML for runtime behavior (type, required, default, action), while YAML metadata like help and choices is merged in.

Documentation

Full documentation is available at arglite.readthedocs.io.

Installation

pip install arglite

Notes

  • Flags are case-sensitive.
  • Both -f / --flag and --flag=value / -f=value syntaxes are supported.
  • Values containing spaces work when passed via the shell's normal quoting rules.
  • Empty string values (--name "") are preserved.
  • ast.literal_eval is used for type inference when no explicit type is given.

Metadata

Release files for arglite 0.30.5

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

Source distribution (sdist)

Source distribution for arglite 0.30.5
File Size Uploaded Provenance Actions
arglite-0.30.5.tar.gz 14.2 kB Without provenance Details for arglite-0.30.5.tar.gz

Built distribution (wheel)

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

Total release size: 25.9 kB

Release files / arglite-0.30.5.tar.gz

Download URL arglite-0.30.5.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b86e745f56cd3b1f39bb5afb1455d44635800e27952570682d94506be2b50049
BLAKE2b-256 checksum
How to use checksums
5e21c99f305e1fc40c69b9434eeaeb99812bd54f26d27cbec038b9f16d736636
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / arglite-0.30.5-py3-none-any.whl

Download URL arglite-0.30.5-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d34dcba2675f37ed91f02e1d310c88ee28db641c120212912a3c10009e606201
BLAKE2b-256 checksum
How to use checksums
e175c68989c26d313ab9b11b26c68ba73bec0e0b90b7d629550dd20ad4af83e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for arglite 0.30.5

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