Devtools for the Pydantic library
Project description
pydantic-devtools
A collection of utilities to facilitate debugging of Pydantic's internals.
Pretty-print core schemas
The pps() function can be used to debug Pydantic core schemas:
class Model(BaseModel): ...
# If the provided argument is a Pydantic model/dataclass type adapter,
# the core schema is automatically fetched:
pps(
Model,
max_depth=2, # Default: None
strip_metadata=False # Default: True
)
> {
> 'type': 'model',
> ...,
> }
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
PYTHONBREAKPOINTenvironment variable topydantic_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 (same as the pps() function):
(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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_devtools-0.3.0.tar.gz.
File metadata
- Download URL: pydantic_devtools-0.3.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4bfeb886055edf52a2fda32fe2592d665e459d34f277a1530d374f380a47187
|
|
| MD5 |
f50749370c58b6c125045d05b7c5d3fc
|
|
| BLAKE2b-256 |
e201c9700fba7739c4ba3adcd1c3952233f351fca6cfe713928aa42c60f5cd69
|
File details
Details for the file pydantic_devtools-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_devtools-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd2e1c62cf2d3baa678ca14041cb04e49e08222fee20d38868c40b660e35164f
|
|
| MD5 |
661af9e6e55eb6d9a67f5e3994cefdf8
|
|
| BLAKE2b-256 |
bfb7ac88a3993f83ea0f1ab942374ebecdce055deefae6d024475c8999f4c00b
|