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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for pyyaml_typed-0.1.4.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da4f612d2076dad62fe48cb1bdff349f7e15b16b6354264e5d0b78a99bfb7bcf |
|
MD5 | 411ad46fe6bbc6fd21252b89758f6a31 |
|
BLAKE2b-256 | cb4b3950591b431f7690593d399cd7d7340cef6dec5f6576a7a2fe72f79eec8b |