Getting Started

Installation

diagnostic is available on PyPI and can be installed with pip:

pip install diagnostic

Usage

This library’s core functionality is provided by diagnostic.Diagnostic. This class serves as an abstract base class for objects that contain diagnostic information, and is intended to be used as a base class for subclasses.

There are two concrete implementations provided:

>>> from diagnostic import DiagnosticError
>>> path = "/path/to/config.yml"
>>> raise DiagnosticError(
...     code="configuration-not-found",
...     message="Configuration file not found",
...     causes=[
...         f"The configuration file was expected to be at {path}",
...     ],
...     hint_stmt="Please create the expected configuration file.",
...     note_stmt="`--config` option allows use of a different path.",
... )
Traceback (most recent call last):
    ...
diagnostic.DiagnosticError: configuration-not-found

Configuration file not found

Caused by:
--> The configuration file was expected to be at /path/to/config.yml

note: `--config` option allows use of a different path.
hint: Please create the expected configuration file.
>>> import rich
>>> rich.print(
...     DiagnosticError(
...         code="configuration-not-found",
...         message="Configuration file not found",
...         causes=[
...             f"The configuration file was expected to be at {path}",
...         ],
...         hint_stmt="Please create the expected configuration file.",
...         note_stmt="`--config` option allows use of a different path.",
...     )
... )
error: configuration-not-found

× Configuration file not found
╰─> The configuration file was expected to be at /path/to/config.yml

note: `--config` option allows use of a different path.
hint: Please create the expected configuration file.