Skip to main content

report voluptuous errors

Project description

https://pepy.tech/badge/voluptuous_errors/month https://github.com/KenKundert/voluptuous_errors/actions/workflows/build.yaml/badge.svg https://coveralls.io/repos/github/KenKundert/voluptuous_errors/badge.svg?branch=master https://img.shields.io/pypi/v/voluptuous_errors.svg https://img.shields.io/pypi/pyversions/voluptuous_errors.svg
Author:

Ken Kundert

Version:

0.0.0

Released:

2024-02-25

A convenience function used for reporting voluptuous errors from nestedtext with inform. Here is a typical use of this function:

>>> from voluptuous import Schema, Invalid, MultipleInvalid, Required
>>> from voluptuous_errors import report_voluptuous_errors
>>> from inform import error, os_error, terminate
>>> import nestedtext as nt

>>>  try:
...      settings_path = Path('settings.nt')
...      settings = nt.load(
...          settings_path,
...          keymap = (keymap:={}),
...      )
...      settings = schema(settings)
>>>  except nt.NestedTextError as e:
...      e.report()
>>>  except MultipleInvalid as e:
...      report_voluptuous_errors(e, keymap, settings_path)
>>>  except OSError as e:
...      error(os_error(e))
>>>  terminate()

This code reports all errors found by Voluptuous when reading the settings file. It employs the NestedText keymap facility to annotate the error messages with helpful context such as line numbers.

You can map Voluptuous error messages by importing and modifying voluptuous_error_msg_mappings. For example:

voluptuous_error_msg_mappings["expected a table name"] = ("unknown table.", "key")

The value consists of two values, the new message, and the location they message refers to. This second value may be either “key” or “value”.

Releases

Latest development release:
Version: 0.0.0
Released: 2024-03-25
0.0 (2024-02-25):

Initial version.

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

voluptuous_errors-0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

voluptuous_errors-0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file voluptuous_errors-0.1.tar.gz.

File metadata

  • Download URL: voluptuous_errors-0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for voluptuous_errors-0.1.tar.gz
Algorithm Hash digest
SHA256 787bf743d0ccb41412ac3875730142a5e12c44e0fb6f33658e65a8c7538cc657
MD5 debd81bb5bd6e9ed172bfe0879c61bf3
BLAKE2b-256 c4a5a62df80cb7088cdae0a0cf89ee71afb8867168d98873d7c16ebca0a9bafa

See more details on using hashes here.

File details

Details for the file voluptuous_errors-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for voluptuous_errors-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eadb638db1c8011303c31dc8de28d61b2a8e6f76dafe6f21d1953863962f663d
MD5 fc8eebaf5debf5e6e061919410a1dc3a
BLAKE2b-256 f7c5f3f2c30d3a505ec090b746abd00e2447057155b79135be62b3bb5aa7b5a7

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