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-0.0.2.tar.gz
(7.0 kB
view details)
Built Distribution
File details
Details for the file with_argparse-0.0.2.tar.gz
.
File metadata
- Download URL: with_argparse-0.0.2.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01d8068da07bf87b57ed28eefe89dd807498c1f54d8834d796011ab1478decc7 |
|
MD5 | bb44abb04412141bc68ecf42c6138a5b |
|
BLAKE2b-256 | 39467e4518fe31f5ccc016dbaf768f1926450495da89217649ba72657257a481 |
File details
Details for the file with_argparse-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: with_argparse-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.4 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 | 9bce02b5568827c621e8fba1d869a1b78ca2a51d6055588f2fab9e7ba51a0488 |
|
MD5 | 2831ac8a92c1cb1c5049dec917649e71 |
|
BLAKE2b-256 | a544b21b97c2e0ff579cf219e46e1d12c02fa61cc9b42dddbbe75285a7dd1f4f |