Skip to main content

No project description provided

Project description

TypedArgs

Build Status

Strong type args.

Install

From pypi

pip install typed-args

From github

pip install git+https://github.com/SunDoge/typed-args.git@v0.3

Usage

from dataclasses import dataclass

from typed_args import TypedArgs, add_argument


@dataclass
class Args(TypedArgs):
    data: str = add_argument('data', metavar='DIR', help='path to dataset')
    arch: str = add_argument('-a', '--arch', metavar='ARCH', default='resnet18',
                             help='model architecture (default: resnet18)')
    num_workers: int = add_argument('-j', '--workers', default=4, metavar='N',
                                    help='number of data loading workers (default: 4)')


def test_args():
    data = '/path/to/dataset'
    arch = 'resnet50'
    num_workers = 8

    argv = f'{data} -a {arch} --workers {num_workers}'.split()

    args = Args.from_args(argv)

    assert args.arch == arch
    assert args.data == data
    assert args.num_workers == num_workers


if __name__ == "__main__":
    test_args()

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

typed-args-0.3.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

typed_args-0.3.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file typed-args-0.3.1.tar.gz.

File metadata

  • Download URL: typed-args-0.3.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.6

File hashes

Hashes for typed-args-0.3.1.tar.gz
Algorithm Hash digest
SHA256 8ee11b875dc082bb3eec791eb775e59b1488fa6296822a7bef23d8f3f9095f1e
MD5 88cbe793593c8fd19728fccff2aec3ea
BLAKE2b-256 f2698d4670b30c7954c6651d1342262c1904e279323227c8ce124780dac12ee1

See more details on using hashes here.

File details

Details for the file typed_args-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: typed_args-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.6

File hashes

Hashes for typed_args-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 baa324462377070625b180391f35f2dbd1fb66697054ff3aaf8ff978c37995aa
MD5 b6240a11bbe4087b3e3dcc4b6c1de767
BLAKE2b-256 f1d8bf8ab7cd8d64c1969803e5905bfc43eb0669a1827c16c51de518ca872ae2

See more details on using hashes here.

Supported by

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