Skip to content

KenKundert/voluptuous_errors

Repository files navigation

Voluptuous Errors — Voluptuous Error Reporting when using NestedText and Inform

https://pepy.tech/badge/voluptuous_errors/month https://coveralls.io/repos/github/KenKundert/voluptuous_errors/badge.svg?branch=master
Author:Ken Kundert
Version:0.2
Released:2026-06-28

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.2
Released: 2026-06-28

0.2 (2026-06-28)

  • Return error count

0.1 (2026-06-10)

  • Improve error message (include value as codicil if appropriate).

0.0 (2024-02-25)

  • Initial version.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages