A dataclass generate library for Namespace object generated by argparse
# 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 .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 !
...cd tests
python -m unittestcd tests
python -m build
twine upload --repository testpypi dist/*