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.1.tar.gz
(6.9 kB
view details)
Built Distribution
File details
Details for the file with_argparse-0.0.1.tar.gz
.
File metadata
- Download URL: with_argparse-0.0.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6cfc65e214c9bfec9fd4ce43480f8ec1213f9a285beaf04adc6ed830a712c14 |
|
MD5 | 4ba030e633d6e6fe4614464dc7468c01 |
|
BLAKE2b-256 | 4edef5ff1dd4191bfc6e8babfaae58d7fbcad4abe1fe2b96e370c786594fd1f7 |
File details
Details for the file with_argparse-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: with_argparse-0.0.1-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 | cec9c7911ee0816f4c437065428b08b8b0fb979181c0cac259a5778153d01e98 |
|
MD5 | 9d8c2226b51bc7f0150a885a0388d7ee |
|
BLAKE2b-256 | 7831a76051debf06dd7f5eb48b94f324cfe3023d49fadd686614542f3544c96f |