Skip to main content

yaml-error-report

pipeline status coverage report

Generate rich console errors reports for YAML (and JSON, since its a YAML subset) documents. This is aimed at console tools which want to present the user with useful errors messages if a YAML or JSON document fails some internal validation.

Uses PyYaml to extract location (line, column, position in stream) information for nodes in a YAML or JSON document. This information can then be used to create user friendly error reports.

Can be combined with jsonschema, to greatly improve error messages. See examples\with_jsonschema.

Installation

pip install yaml-error-report

Usage

# calc.yml
name: calc

methods:
  - name: sum
    description: "Sums x and y"
    request:
      - name: "x"
        type: Int36
      - name: "y"
        type: Int32
    response: Int32
# windows only: needed to make coloured output work
import colorama
colorama.init()

from yaml_error_report import path_to_location, error_report

# extract the text location of the offending node
loc = path_to_location("calc.yml", ["methods", 0, "request", 0, "type"])
# create the error report
error = error_report("YAML Validation Error", "Int36 is not a valid type", loc)
print(error)

outputs (nicely coloured on terminals)

YAML Validation Error
   --> calc.yml:8:14
   7|         - name: "x"
   8|           type: Int36
                      ^^^^^ Int36 is not a valid type
   9|         - name: "y"
  10|           type: Int32

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.

yaml_error_report-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file yaml_error_report-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yaml_error_report-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for yaml_error_report-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e99b94910e212dc926dbd0f357275b3f9966ca43a278de078cea6abc7580c81
MD5 2f0580de625c7b933b55c197e3f5b821
BLAKE2b-256 3ced144821e1420b084fb3a07219a9185d3fc577c1acf5da74001db10c885d67

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page