GitXplorerGitXplorer
V

pydantic-devtools

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.

No commits found

There are no commits on branch main.

README

The README file for this repository.

pydantic-devtools

A collection of utilities to facilitate debugging of Pydantic's internals.

The Pydantic debugger

pydantic-devtools provides a custom Pdb class, adding various commands.pps (pretty-print schema) command to debug Pydantic core schemas.

To use the Pydantic debugger:

  • set the PYTHONBREAKPOINT environment variable to pydantic_devtools.pdb.
  • In your code, add a breakpoint() call. The Pydantic debugger will be used.

pps command

The pps (pretty-print schema) command can be used to debug Pydantic core schemas:

(Pydantic pdb) pps schema
{
    'type': 'model-field',
    'schema': {'type': 'definition-ref', 'schema_ref': '...'},
    'metadata': {'<stripped>'}
}

By default, generic metadata (related to JSON Schema generation) is stripped.

Optionally, a max_depth argument can be provided (pps <schema> <depth>). A default value can also be specified as a keyword argument to breakpoint().

pc command

The pc (Pydantic context) command can be used to get information related to the current schema generation process:

pc command example