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.7rc1.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for with_argparse-0.0.7rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ef7e57b3d371c10a4b3d16623d12d0eae2268bde4bb9d2602c48560dbc6a84d |
|
MD5 | 43253c410417790f446930b03d80306b |
|
BLAKE2b-256 | 492eeeca5b20ccf8aad608edc754a1ceebd55b9fb3b7db8fd8435316e1cead9a |