A simple but handy Python library to generate a `argparse.ArgumentParser` object from a type-annotated method
Project description
with-argparse
with-argparse
is a very simple and tiny package adding support to create
and apply argparse.ArgumentParser
objects automatically using the type
annotations from a given python method:
from pathlib import Path
from with_argparse import with_argparse
@with_argparse
def sample_method(
text_input: str, # required argument
another_text_input: str = None, # default argument
output_dir: Path = None,
flag: bool = False,
):
pass
sample_method()
will generate the argparse output:
usage: scratch_2.py [-h] --text_input TEXT_INPUT
[--another_text_input ANOTHER_TEXT_INPUT]
[--output_dir OUTPUT_DIR] [--flag]
Boolean values
- A
True
boolean default fieldflag
is converted to--no_flag
Configurability
with_opt_argparse
allows to override some of the default settings used
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
with_argparse-1.0.0rc1.tar.gz
(11.2 kB
view details)
Built Distribution
File details
Details for the file with_argparse-1.0.0rc1.tar.gz
.
File metadata
- Download URL: with_argparse-1.0.0rc1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61016f4e15002aa017f0872b11139add90cba5d4094ed1a769daf2b1e4c8f10f |
|
MD5 | c7c26a8e3baae70980dfab250d543ad8 |
|
BLAKE2b-256 | e1a9aa42c79bad7538eec1cc969115ecefe9be430f673deee9f137b1552fd170 |
File details
Details for the file with_argparse-1.0.0rc1-py3-none-any.whl
.
File metadata
- Download URL: with_argparse-1.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c6048188f377737bfef56b554890614ea1ba13c04cec5ba830a17f9d8a0818c |
|
MD5 | 56ff43b596aef5f1497bacf60a81a131 |
|
BLAKE2b-256 | 4be4839de18fb48baf9974bf20e8941d543d087945ff46beedc86153abd6162e |