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.2.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for fucking_argparse-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53f7bf68c572f3b2f0c98da38ec7df598467654f1e1bc086083adb2e7431b7cf |
|
MD5 | 2bba6999aefeee1ca72c22e0c2bc2e4a |
|
BLAKE2b-256 | 02c1c8f7fc70ab55dccf48b09194e5b47521eee6d911539f8d8722c985b45823 |