Skip to main content

PyYAML dumper/loader using field descriptions in class comments

Project description

pyyaml-typed

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

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


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 details)

Uploaded Source

Built Distribution

pyyaml_typed-0.1.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pyyaml-typed-0.1.3.tar.gz.

File metadata

  • Download URL: pyyaml-typed-0.1.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1032-gcp

File hashes

Hashes for pyyaml-typed-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5ec3069b003c9baab17062881976044bdfadb927810f4277f04678c0c1f47eee
MD5 a2372835b26452065cfa6047a5369fdb
BLAKE2b-256 61dccfa2102e4df8e5f0519e7a5695ad6a55bd33c89d01608924e3f52eeb5ff9

See more details on using hashes here.

File details

Details for the file pyyaml_typed-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyyaml_typed-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.1 Linux/5.4.0-1032-gcp

File hashes

Hashes for pyyaml_typed-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c330561e12008b619d406eb3bd69d09529f00614f571f4b7e47e4ae1e0965a7b
MD5 6c8990d17d5bf4cefbca58af61d821a2
BLAKE2b-256 09fdccd409793d30eb4019c05d644c065fed54ce962f52648c6aac5c48eb9343

See more details on using hashes here.

Supported by

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