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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyyaml_typed-0.1.4.0a1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file pyyaml_typed-0.1.4.0a1-py3-none-any.whl.

File metadata

  • Download URL: pyyaml_typed-0.1.4.0a1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.1

File hashes

Hashes for pyyaml_typed-0.1.4.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b5a0373e2748b278ebc4e250c13aeba0c852015a311dd6c999c35954af231ec
MD5 462149b4b92bdd932e2518e0f47069d5
BLAKE2b-256 4714a1a238e0e273c5d3c0060a2338ea060af2bb528a61faa59b334ed7a6471b

See more details on using hashes here.

Supported by

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