Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Serves modern approach to data structures definition - with a minimal boilerplate.

Project description


Python's 3.7 dataclasses got maried with pyyaml.


pip install matiz

Usage example:

import dataclasses
import matiz
from matiz import fields

class Some(matiz.ObsoleteAble):
    id: int = fields.Integer()
    mac: str = fields.MacAddress()
    ip: str = fields.IPv4()
    version: int = fields.Integer(default=411)

Now the Some object can be created as a pure python object (thanks to dataclass) it is equipped with __init__, __repr__, __eq__ and some other methods.

>>> obj = Some(123, 'aa:bb:cc:11:22:33', '')
>>> obj
Some(id=123, mac='aa:bb:cc:11:22:33', ip='', version=411)

>>> print(obj)
id: 123
mac: aa:bb:cc:11:22:33
version: 411

It's attributes are regular python attributes:


>>> obj.mac

>>> obj.ip

>>> obj.version = 0  # can be assigned
>>> print(repr(obj))
Ints(id=123, mac='aa:bb:cc:11:22:33', ip='', version=0)

It can be also deserialized from yaml directly to the custom object:

>>> yaml_string = """
id: 22001
mac: aa:bb:cc:11:22:33
version: 0

>>> import yaml
>>> obj2 = yaml.load(yaml_string, Loader=yaml.Loader)
>>> repr(obj2)
Some(id=22001, mac='aa:bb:cc:11:22:33', ip='', version=0)

To be further documented...

Project details

Release history Release notifications

Download files

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

Files for matiz, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size matiz-0.1.4-py2.py3-none-any.whl (23.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size matiz-0.1.4.tar.gz (10.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page