yaml-error-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
Metadata
Release files for yaml-error-report 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yaml_error_report-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / yaml_error_report-0.1.0-py3-none-any.whl
| Download URL | yaml_error_report-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e99b94910e212dc926dbd0f357275b3f9966ca43a278de078cea6abc7580c81
|
|
BLAKE2b-256 checksum How to use checksums |
3ced144821e1420b084fb3a07219a9185d3fc577c1acf5da74001db10c885d67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for yaml-error-report 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.