ddp_utils.devtools

import ddp_utils.devtools

Normalize arbitrary Python objects for readable diagnostic output.

The helpers recursively convert dataclasses, date and time values, enums, and nested collections into JSON-serializable structures while detecting cyclic references.

Examples

Use this public operation:

from ddp_utils.devtools import debug

debug({"status": "ready"})
ddp_utils.devtools.debug_v1(o)

Print a recursively normalized representation as indented JSON.

Dataclasses, enums, paths, byte sequences, date and time values, mappings, collections, and custom objects receive type-aware representations. Repeated references are rendered as recursion markers. Unsupported values fall back to repr and then to an <unreprable:TypeName> marker.

Parameters

Name

Description

o

Object to normalize and write to standard output.

Raises

Exception

Description

TypeError

The normalized value still contains a value unsupported by the JSON encoder, such as a non-serializable enum value.

Examples

Print a nested diagnostic value:

from ddp_utils.devtools import debug_v1

debug_v1({"worker": 3, "ready": True})
ddp_utils.devtools.debug(o)

Print an arbitrary Python object as indented, readable JSON.

The normalization detects reference cycles and memoizes already converted objects. Dataclasses include a __type__ field. Unsupported objects fall back to repr and then to an <unreprable:TypeName> marker if their representation also fails.

Parameters

Name

Description

o

Object to normalize and print, including dataclasses, mappings, collections, date and time values, enums, and custom instances.

Examples

Print a nested diagnostic value to standard output:

from ddp_utils.devtools import debug

debug({"worker": 3, "ready": True})