Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

PyYAML dumper/loader using field descriptions in class comments

Project description


Build Status codecov PyPI version GitHub

Library providing dump and load functions for pyyaml supporting go-yaml-like description of yaml fields as class comments

Dataclasses and named tuples can be used without defining field names. Field in comment for them will override default class field name


from tyaml import dump

class Something:
    my_fld_1: int
    # or use `yaml:` comment to rename
    field2: str  # yaml: my_fld_2
output = dump([Something(1, "that's"), Something(2, "nice")])

will create yaml:

- my_fld_1: 1
  my_fld_2: "that's"
- my_fld_1: 2
  my_fld_2: "nice"

and in the opposite direction:

from typing import List

from tyaml import load

loaded = load(yml_str, List[Something])
loaded == [Something(1, "that's"), Something(2, "nice")]

Project details

Download files

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

Files for pyyaml-typed, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size pyyaml_typed-0.1.3-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyyaml-typed-0.1.3.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page