Skip to main content

A simple tool to use dataclass as your config

Project description

ci python-version pypi

Argdcls

A simple tool to use dataclass as your config.

Usage

from dataclasses import dataclass

import argdcls


@dataclass
class Config:
    lr: float
    adam: bool = False


config = argdcls.load(Config)
print(config)
$ python3 main.py @lr=1.0
Config(lr=1.0, adam=False)
$ python3 main.py lr=1.0 adam=True
Config(lr=1.0, adam=True)
$ python3 main.py lr=1.0 adm=True # typo!
Parameter \"adm\" is not in the dataclass fields: ['lr', 'adam'].
$ python3 main.py lr=1.0 @adam=True # avoid overwriting
Parameter "adam" must have no default value but have default value: "False". You may use "adam=True" instead.

@param=value avoids overwriting the default values.

Benefits

  • Attribute suggestions from IDEs (e.g., config.a<tab> indicates config.adam)

License

MIT

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

argdcls-0.5.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

argdcls-0.5.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file argdcls-0.5.0.tar.gz.

File metadata

  • Download URL: argdcls-0.5.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.0 Darwin/20.3.0

File hashes

Hashes for argdcls-0.5.0.tar.gz
Algorithm Hash digest
SHA256 385d03d3fb20fa2d2486ab6b9d961fdb81779fba04dcd40aad1752039b4039af
MD5 0c594dcfecfed312099bbbfabb4b34a4
BLAKE2b-256 0fd59f82e228e60221f42239583d11f06fa0f79b64fe6be1a6c2d84a4f460e48

See more details on using hashes here.

File details

Details for the file argdcls-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: argdcls-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.0 Darwin/20.3.0

File hashes

Hashes for argdcls-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6681f5cb5c4f40774a1a73e69dd27965542c7a9833811c52dce3b9c44f02451b
MD5 0d9d2c87b87fcf58f1527b0991249ab7
BLAKE2b-256 b8e6e28c186bf65fa61cecd0c539be8d8e1e2892a2681447c75f3aeb0311d6ce

See more details on using hashes here.

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