Skip to main content

No project description provided

Project description

anton

CI testing pre-commit Documentation Status

anton is a Python library for auto instantiating yaml definitions to user defined dataclasses.

Avoid boilerplate and get runtime type checking before the objects are created.

Usage

Given a yaml file definition in a file index.yaml as follows:

# index.yaml
integer: 23
string: "Hello world"
point:
  x: 0
  y: 0
line_segment:
  first_point:
    x: 10
    y: 10
  second_point:
    x: 10
    y: 10

yaml_conf lets you avoid writing the biolerplate code for loading the yaml file and parsing the python dictionary to instantiate the Dataclass object as follows:

>>> from dataclasses import dataclass
>>> from anton import yaml_conf
>>>
>>> @dataclass
... class Point:
...     x: int
...     y: int
...
>>> @dataclass
... class LineSegment:
...     first_point: Point
...     second_point: Point
...
>>> @yaml_conf(conf_path="index.yaml")
... class ExampleClass:
...     integer: int
...     string: str
...     point: Point
...     line_segment: LineSegment
...
>>> example_obj = ExampleClass()
>>> example_obj
ExampleClass(integer=23, string='Hello world', point=Point(x=0, y=0), line_segment=LineSegment(first_point=Point(x=10, y=10), second_point=Point(x=10, y=10)))

Roadmap

Currently the project only supports Python3.8

Runtime type checking is supported for the following types:

  • int
  • float
  • str
  • bool
  • typing.List
  • typing.Dict
  • typing.Union
  • Any user defined dataclass

The ultimate aim is to support all python versions Python3.8+ and all possible type combinations.

Contributing

Pull requests are welcome !!! Please make sure to update tests as appropriate.

For major changes, please open an issue first to discuss what you would like to change.

Please do go through the Contributing Guide if some help is required.

Note: anton currently in active development. Please open an issue if you find anything that isn't working as expected.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anton-0.2.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anton-0.2.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file anton-0.2.0.tar.gz.

File metadata

  • Download URL: anton-0.2.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.6 Linux/5.19.0-35-generic

File hashes

Hashes for anton-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fc8a183fc91ed41fbbde522282bd4c4c30db9896a2d29058d99fc02cfc7933d3
MD5 c22aa7488b4be72a335e2d1ba95b7d42
BLAKE2b-256 8ed112637b0e0e0ddd3645e4908c16f3a648dafa1a82ae78ea00e4db262457a6

See more details on using hashes here.

File details

Details for the file anton-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: anton-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.6 Linux/5.19.0-35-generic

File hashes

Hashes for anton-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c2d9c5685f6d5c84d9d9bd831e3557a7d1391bbb2a17d55c811037f8d7c5a77
MD5 aa2096ee4f94a3460de1fcaf259a1223
BLAKE2b-256 f04fe1441b6a13e60dbdb437ceaf627677438ed67a89217be9804a4041b8109e

See more details on using hashes here.

Supported by

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