PyYAML dumper/loader using field descriptions in class comments
Project description
pyyaml-typed
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
Example:
from tyaml import dump @dataclass 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyyaml-typed-0.1.3.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for pyyaml_typed-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c330561e12008b619d406eb3bd69d09529f00614f571f4b7e47e4ae1e0965a7b |
|
MD5 | 6c8990d17d5bf4cefbca58af61d821a2 |
|
BLAKE2-256 | 09fdccd409793d30eb4019c05d644c065fed54ce962f52648c6aac5c48eb9343 |