A dataclass generate library for Namespace object generated by argparse
Project description
Fucking Argparse
A dataclass generate library for Namespace object generated by argparse
install
# install via TestPyPI
pip install -i https://test.pypi.org/simple/ fucking-argparse
# install via source
git clone https://github.com/Shadowsight9/fucking-argparse.git
cd fucking-argparse
pip install --editable .
Usage
Step1: insert code
import argparse
# import
from fucking_argparse import gen_codes
parser = argparse.ArgumentParser()
parser.add_argument("--inductor", type=str, default="rule")
parser.add_argument("--group_beam", type=bool, default=False)
parser.add_argument("--mlm_training", type=bool, default=False)
parser.add_argument("--bart_training", type=bool, default=False)
parser.add_argument("--if_then", type=bool, default=False)
parser.add_argument("--task", type=str, default="openrule155")
args = parser.parse_args()
# insert gen_codes function after read and preprocess arguments
gen_codes(args=args, file_path="./arguments.py")
# exit process for modify code to run again
exit()
Step2: add type hint
# import generated arguments file
from arguments import Arguments
# init `dataclass` to replace typeless `Namespace`
args = Arguments()
# enjoy a safe replay process with type hints !
...
Test
cd tests
python -m unittest
Build and publish
cd tests
python -m build
twine upload --repository testpypi dist/*
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
fucking_argparse-0.0.3.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for fucking_argparse-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 554ecab010cc5a89360e8f3bac0ce094d9d7b5c188f58c5cfb69eee87a024b16 |
|
MD5 | 9fa68f62f02499d2d33426c89ecb7f7b |
|
BLAKE2b-256 | c2f65446f4ddef92f892f8affa39e72431bb3da697da2f064062acc4a92a25fa |