Skip to main content

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


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)

Uploaded Source

Built Distribution

fucking_argparse-0.0.3-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page