Add loan-advisor-agent
Browse files- .gitattributes +2 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__init__.py +171 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__pycache__/__init__.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__pycache__/core_schema.cpython-312.pyc +3 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/_pydantic_core.cp312-win_amd64.pyd +3 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/_pydantic_core.pyi +1056 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/core_schema.py +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/py.typed +0 -0
.gitattributes
CHANGED
|
@@ -543,3 +543,5 @@ loan-advisor-agent/.venv/Lib/site-packages/pyarrow/parquet.lib filter=lfs diff=l
|
|
| 543 |
loan-advisor-agent/.venv/Lib/site-packages/pyarrow.libs/msvcp140-f22b3317cfb3fad7db3a18f8f234f32b.dll filter=lfs diff=lfs merge=lfs -text
|
| 544 |
loan-advisor-agent/.venv/Lib/site-packages/pydantic/__pycache__/json_schema.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 545 |
loan-advisor-agent/.venv/Lib/site-packages/pydantic/_internal/__pycache__/_generate_schema.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 543 |
loan-advisor-agent/.venv/Lib/site-packages/pyarrow.libs/msvcp140-f22b3317cfb3fad7db3a18f8f234f32b.dll filter=lfs diff=lfs merge=lfs -text
|
| 544 |
loan-advisor-agent/.venv/Lib/site-packages/pydantic/__pycache__/json_schema.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 545 |
loan-advisor-agent/.venv/Lib/site-packages/pydantic/_internal/__pycache__/_generate_schema.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 546 |
+
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__pycache__/core_schema.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 547 |
+
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/_pydantic_core.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__init__.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import sys as _sys
|
| 4 |
+
from typing import Any as _Any
|
| 5 |
+
|
| 6 |
+
from typing_extensions import Sentinel
|
| 7 |
+
|
| 8 |
+
from ._pydantic_core import (
|
| 9 |
+
ArgsKwargs,
|
| 10 |
+
MultiHostUrl,
|
| 11 |
+
PydanticCustomError,
|
| 12 |
+
PydanticKnownError,
|
| 13 |
+
PydanticOmit,
|
| 14 |
+
PydanticSerializationError,
|
| 15 |
+
PydanticSerializationUnexpectedValue,
|
| 16 |
+
PydanticUndefined,
|
| 17 |
+
PydanticUndefinedType,
|
| 18 |
+
PydanticUseDefault,
|
| 19 |
+
SchemaError,
|
| 20 |
+
SchemaSerializer,
|
| 21 |
+
SchemaValidator,
|
| 22 |
+
Some,
|
| 23 |
+
TzInfo,
|
| 24 |
+
Url,
|
| 25 |
+
ValidationError,
|
| 26 |
+
__version__,
|
| 27 |
+
from_json,
|
| 28 |
+
to_json,
|
| 29 |
+
to_jsonable_python,
|
| 30 |
+
)
|
| 31 |
+
from .core_schema import CoreConfig, CoreSchema, CoreSchemaType, ErrorType
|
| 32 |
+
|
| 33 |
+
if _sys.version_info < (3, 11):
|
| 34 |
+
from typing_extensions import NotRequired as _NotRequired
|
| 35 |
+
else:
|
| 36 |
+
from typing import NotRequired as _NotRequired
|
| 37 |
+
|
| 38 |
+
if _sys.version_info < (3, 12):
|
| 39 |
+
from typing_extensions import TypedDict as _TypedDict
|
| 40 |
+
else:
|
| 41 |
+
from typing import TypedDict as _TypedDict
|
| 42 |
+
|
| 43 |
+
__all__ = [
|
| 44 |
+
'__version__',
|
| 45 |
+
'UNSET',
|
| 46 |
+
'CoreConfig',
|
| 47 |
+
'CoreSchema',
|
| 48 |
+
'CoreSchemaType',
|
| 49 |
+
'SchemaValidator',
|
| 50 |
+
'SchemaSerializer',
|
| 51 |
+
'Some',
|
| 52 |
+
'Url',
|
| 53 |
+
'MultiHostUrl',
|
| 54 |
+
'ArgsKwargs',
|
| 55 |
+
'PydanticUndefined',
|
| 56 |
+
'PydanticUndefinedType',
|
| 57 |
+
'SchemaError',
|
| 58 |
+
'ErrorDetails',
|
| 59 |
+
'InitErrorDetails',
|
| 60 |
+
'ValidationError',
|
| 61 |
+
'PydanticCustomError',
|
| 62 |
+
'PydanticKnownError',
|
| 63 |
+
'PydanticOmit',
|
| 64 |
+
'PydanticUseDefault',
|
| 65 |
+
'PydanticSerializationError',
|
| 66 |
+
'PydanticSerializationUnexpectedValue',
|
| 67 |
+
'TzInfo',
|
| 68 |
+
'to_json',
|
| 69 |
+
'from_json',
|
| 70 |
+
'to_jsonable_python',
|
| 71 |
+
]
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class ErrorDetails(_TypedDict):
|
| 75 |
+
type: str
|
| 76 |
+
"""
|
| 77 |
+
The type of error that occurred, this is an identifier designed for
|
| 78 |
+
programmatic use that will change rarely or never.
|
| 79 |
+
|
| 80 |
+
`type` is unique for each error message, and can hence be used as an identifier to build custom error messages.
|
| 81 |
+
"""
|
| 82 |
+
loc: tuple[int | str, ...]
|
| 83 |
+
"""Tuple of strings and ints identifying where in the schema the error occurred."""
|
| 84 |
+
msg: str
|
| 85 |
+
"""A human readable error message."""
|
| 86 |
+
input: _Any
|
| 87 |
+
"""The input data at this `loc` that caused the error."""
|
| 88 |
+
ctx: _NotRequired[dict[str, _Any]]
|
| 89 |
+
"""
|
| 90 |
+
Values which are required to render the error message, and could hence be useful in rendering custom error messages.
|
| 91 |
+
Also useful for passing custom error data forward.
|
| 92 |
+
"""
|
| 93 |
+
url: _NotRequired[str]
|
| 94 |
+
"""
|
| 95 |
+
The documentation URL giving information about the error. No URL is available if
|
| 96 |
+
a [`PydanticCustomError`][pydantic_core.PydanticCustomError] is used.
|
| 97 |
+
"""
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class InitErrorDetails(_TypedDict):
|
| 101 |
+
type: str | PydanticCustomError
|
| 102 |
+
"""The type of error that occurred, this should be a "slug" identifier that changes rarely or never."""
|
| 103 |
+
loc: _NotRequired[tuple[int | str, ...]]
|
| 104 |
+
"""Tuple of strings and ints identifying where in the schema the error occurred."""
|
| 105 |
+
input: _Any
|
| 106 |
+
"""The input data at this `loc` that caused the error."""
|
| 107 |
+
ctx: _NotRequired[dict[str, _Any]]
|
| 108 |
+
"""
|
| 109 |
+
Values which are required to render the error message, and could hence be useful in rendering custom error messages.
|
| 110 |
+
Also useful for passing custom error data forward.
|
| 111 |
+
"""
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class ErrorTypeInfo(_TypedDict):
|
| 115 |
+
"""
|
| 116 |
+
Gives information about errors.
|
| 117 |
+
"""
|
| 118 |
+
|
| 119 |
+
type: ErrorType
|
| 120 |
+
"""The type of error that occurred, this should be a "slug" identifier that changes rarely or never."""
|
| 121 |
+
message_template_python: str
|
| 122 |
+
"""String template to render a human readable error message from using context, when the input is Python."""
|
| 123 |
+
example_message_python: str
|
| 124 |
+
"""Example of a human readable error message, when the input is Python."""
|
| 125 |
+
message_template_json: _NotRequired[str]
|
| 126 |
+
"""String template to render a human readable error message from using context, when the input is JSON data."""
|
| 127 |
+
example_message_json: _NotRequired[str]
|
| 128 |
+
"""Example of a human readable error message, when the input is JSON data."""
|
| 129 |
+
example_context: dict[str, _Any] | None
|
| 130 |
+
"""Example of context values."""
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
class MultiHostHost(_TypedDict):
|
| 134 |
+
"""
|
| 135 |
+
A host part of a multi-host URL.
|
| 136 |
+
"""
|
| 137 |
+
|
| 138 |
+
username: str | None
|
| 139 |
+
"""The username part of this host, or `None`."""
|
| 140 |
+
password: str | None
|
| 141 |
+
"""The password part of this host, or `None`."""
|
| 142 |
+
host: str | None
|
| 143 |
+
"""The host part of this host, or `None`."""
|
| 144 |
+
port: int | None
|
| 145 |
+
"""The port part of this host, or `None`."""
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
MISSING = Sentinel('MISSING')
|
| 149 |
+
"""A singleton indicating a field value was not provided during validation.
|
| 150 |
+
|
| 151 |
+
This singleton can be used a default value, as an alternative to `None` when it has
|
| 152 |
+
an explicit meaning. During serialization, any field with `MISSING` as a value is excluded
|
| 153 |
+
from the output.
|
| 154 |
+
|
| 155 |
+
Example:
|
| 156 |
+
```python
|
| 157 |
+
from pydantic import BaseModel
|
| 158 |
+
|
| 159 |
+
from pydantic_core import MISSING
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
class Configuration(BaseModel):
|
| 163 |
+
timeout: int | None | MISSING = MISSING
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
# configuration defaults, stored somewhere else:
|
| 167 |
+
defaults = {'timeout': 200}
|
| 168 |
+
|
| 169 |
+
conf = Configuration.model_validate({...})
|
| 170 |
+
timeout = conf.timeout if timeout.timeout is not MISSING else defaults['timeout']
|
| 171 |
+
"""
|
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (3.15 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/__pycache__/core_schema.cpython-312.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:50fb8d1d88f2650f5738a47acb957140aa0dc0b2aee5fefe2ea16e4f458d1e5f
|
| 3 |
+
size 156017
|
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/_pydantic_core.cp312-win_amd64.pyd
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datetime
|
| 2 |
+
from collections.abc import Mapping
|
| 3 |
+
from typing import Any, Callable, Generic, Literal, TypeVar, final
|
| 4 |
+
|
| 5 |
+
from _typeshed import SupportsAllComparisons
|
| 6 |
+
from typing_extensions import LiteralString, Self, TypeAlias
|
| 7 |
+
|
| 8 |
+
from pydantic_core import ErrorDetails, ErrorTypeInfo, InitErrorDetails, MultiHostHost
|
| 9 |
+
from pydantic_core.core_schema import CoreConfig, CoreSchema, ErrorType, ExtraBehavior
|
| 10 |
+
|
| 11 |
+
__all__ = [
|
| 12 |
+
'__version__',
|
| 13 |
+
'build_profile',
|
| 14 |
+
'build_info',
|
| 15 |
+
'_recursion_limit',
|
| 16 |
+
'ArgsKwargs',
|
| 17 |
+
'SchemaValidator',
|
| 18 |
+
'SchemaSerializer',
|
| 19 |
+
'Url',
|
| 20 |
+
'MultiHostUrl',
|
| 21 |
+
'SchemaError',
|
| 22 |
+
'ValidationError',
|
| 23 |
+
'PydanticCustomError',
|
| 24 |
+
'PydanticKnownError',
|
| 25 |
+
'PydanticOmit',
|
| 26 |
+
'PydanticUseDefault',
|
| 27 |
+
'PydanticSerializationError',
|
| 28 |
+
'PydanticSerializationUnexpectedValue',
|
| 29 |
+
'PydanticUndefined',
|
| 30 |
+
'PydanticUndefinedType',
|
| 31 |
+
'Some',
|
| 32 |
+
'to_json',
|
| 33 |
+
'from_json',
|
| 34 |
+
'to_jsonable_python',
|
| 35 |
+
'list_all_errors',
|
| 36 |
+
'TzInfo',
|
| 37 |
+
]
|
| 38 |
+
__version__: str
|
| 39 |
+
build_profile: str
|
| 40 |
+
build_info: str
|
| 41 |
+
_recursion_limit: int
|
| 42 |
+
|
| 43 |
+
_T = TypeVar('_T', default=Any, covariant=True)
|
| 44 |
+
|
| 45 |
+
_StringInput: TypeAlias = 'dict[str, _StringInput]'
|
| 46 |
+
|
| 47 |
+
@final
|
| 48 |
+
class Some(Generic[_T]):
|
| 49 |
+
"""
|
| 50 |
+
Similar to Rust's [`Option::Some`](https://doc.rust-lang.org/std/option/enum.Option.html) type, this
|
| 51 |
+
identifies a value as being present, and provides a way to access it.
|
| 52 |
+
|
| 53 |
+
Generally used in a union with `None` to different between "some value which could be None" and no value.
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
__match_args__ = ('value',)
|
| 57 |
+
|
| 58 |
+
@property
|
| 59 |
+
def value(self) -> _T:
|
| 60 |
+
"""
|
| 61 |
+
Returns the value wrapped by `Some`.
|
| 62 |
+
"""
|
| 63 |
+
@classmethod
|
| 64 |
+
def __class_getitem__(cls, item: Any, /) -> type[Self]: ...
|
| 65 |
+
|
| 66 |
+
@final
|
| 67 |
+
class SchemaValidator:
|
| 68 |
+
"""
|
| 69 |
+
`SchemaValidator` is the Python wrapper for `pydantic-core`'s Rust validation logic, internally it owns one
|
| 70 |
+
`CombinedValidator` which may in turn own more `CombinedValidator`s which make up the full schema validator.
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
# note: pyo3 currently supports __new__, but not __init__, though we include __init__ stubs
|
| 74 |
+
# and docstrings here (and in the following classes) for documentation purposes
|
| 75 |
+
|
| 76 |
+
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None, _use_prebuilt: bool = True) -> None:
|
| 77 |
+
"""Initializes the `SchemaValidator`.
|
| 78 |
+
|
| 79 |
+
Arguments:
|
| 80 |
+
schema: The `CoreSchema` to use for validation.
|
| 81 |
+
config: Optionally a [`CoreConfig`][pydantic_core.core_schema.CoreConfig] to configure validation.
|
| 82 |
+
_use_prebuilt: Whether to use pre-built validators (False during rebuilds to avoid stale references).
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
+
def __new__(cls, schema: CoreSchema, config: CoreConfig | None = None, _use_prebuilt: bool = True) -> Self: ...
|
| 86 |
+
@property
|
| 87 |
+
def title(self) -> str:
|
| 88 |
+
"""
|
| 89 |
+
The title of the schema, as used in the heading of [`ValidationError.__str__()`][pydantic_core.ValidationError].
|
| 90 |
+
"""
|
| 91 |
+
def validate_python(
|
| 92 |
+
self,
|
| 93 |
+
input: Any,
|
| 94 |
+
*,
|
| 95 |
+
strict: bool | None = None,
|
| 96 |
+
extra: ExtraBehavior | None = None,
|
| 97 |
+
from_attributes: bool | None = None,
|
| 98 |
+
context: Any | None = None,
|
| 99 |
+
self_instance: Any | None = None,
|
| 100 |
+
allow_partial: bool | Literal['off', 'on', 'trailing-strings'] = False,
|
| 101 |
+
by_alias: bool | None = None,
|
| 102 |
+
by_name: bool | None = None,
|
| 103 |
+
) -> Any:
|
| 104 |
+
"""
|
| 105 |
+
Validate a Python object against the schema and return the validated object.
|
| 106 |
+
|
| 107 |
+
Arguments:
|
| 108 |
+
input: The Python object to validate.
|
| 109 |
+
strict: Whether to validate the object in strict mode.
|
| 110 |
+
If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
|
| 111 |
+
extra: Whether to ignore, allow, or forbid extra data during model validation.
|
| 112 |
+
If `None`, the value of [`CoreConfig.extra_fields_behavior`][pydantic_core.core_schema.CoreConfig] is used.
|
| 113 |
+
from_attributes: Whether to validate objects as inputs to models by extracting attributes.
|
| 114 |
+
If `None`, the value of [`CoreConfig.from_attributes`][pydantic_core.core_schema.CoreConfig] is used.
|
| 115 |
+
context: The context to use for validation, this is passed to functional validators as
|
| 116 |
+
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
|
| 117 |
+
self_instance: An instance of a model set attributes on from validation, this is used when running
|
| 118 |
+
validation from the `__init__` method of a model.
|
| 119 |
+
allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
|
| 120 |
+
and mappings are ignored.
|
| 121 |
+
`'trailing-strings'` means any final unfinished JSON string is included in the result.
|
| 122 |
+
by_alias: Whether to use the field's alias when validating against the provided input data.
|
| 123 |
+
by_name: Whether to use the field's name when validating against the provided input data.
|
| 124 |
+
|
| 125 |
+
Raises:
|
| 126 |
+
ValidationError: If validation fails.
|
| 127 |
+
Exception: Other error types maybe raised if internal errors occur.
|
| 128 |
+
|
| 129 |
+
Returns:
|
| 130 |
+
The validated object.
|
| 131 |
+
"""
|
| 132 |
+
def isinstance_python(
|
| 133 |
+
self,
|
| 134 |
+
input: Any,
|
| 135 |
+
*,
|
| 136 |
+
strict: bool | None = None,
|
| 137 |
+
extra: ExtraBehavior | None = None,
|
| 138 |
+
from_attributes: bool | None = None,
|
| 139 |
+
context: Any | None = None,
|
| 140 |
+
self_instance: Any | None = None,
|
| 141 |
+
by_alias: bool | None = None,
|
| 142 |
+
by_name: bool | None = None,
|
| 143 |
+
) -> bool:
|
| 144 |
+
"""
|
| 145 |
+
Similar to [`validate_python()`][pydantic_core.SchemaValidator.validate_python] but returns a boolean.
|
| 146 |
+
|
| 147 |
+
Arguments match `validate_python()`. This method will not raise `ValidationError`s but will raise internal
|
| 148 |
+
errors.
|
| 149 |
+
|
| 150 |
+
Returns:
|
| 151 |
+
`True` if validation succeeds, `False` if validation fails.
|
| 152 |
+
"""
|
| 153 |
+
def validate_json(
|
| 154 |
+
self,
|
| 155 |
+
input: str | bytes | bytearray,
|
| 156 |
+
*,
|
| 157 |
+
strict: bool | None = None,
|
| 158 |
+
extra: ExtraBehavior | None = None,
|
| 159 |
+
context: Any | None = None,
|
| 160 |
+
self_instance: Any | None = None,
|
| 161 |
+
allow_partial: bool | Literal['off', 'on', 'trailing-strings'] = False,
|
| 162 |
+
by_alias: bool | None = None,
|
| 163 |
+
by_name: bool | None = None,
|
| 164 |
+
) -> Any:
|
| 165 |
+
"""
|
| 166 |
+
Validate JSON data directly against the schema and return the validated Python object.
|
| 167 |
+
|
| 168 |
+
This method should be significantly faster than `validate_python(json.loads(json_data))` as it avoids the
|
| 169 |
+
need to create intermediate Python objects
|
| 170 |
+
|
| 171 |
+
It also handles constructing the correct Python type even in strict mode, where
|
| 172 |
+
`validate_python(json.loads(json_data))` would fail validation.
|
| 173 |
+
|
| 174 |
+
Arguments:
|
| 175 |
+
input: The JSON data to validate.
|
| 176 |
+
strict: Whether to validate the object in strict mode.
|
| 177 |
+
If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
|
| 178 |
+
extra: Whether to ignore, allow, or forbid extra data during model validation.
|
| 179 |
+
If `None`, the value of [`CoreConfig.extra_fields_behavior`][pydantic_core.core_schema.CoreConfig] is used.
|
| 180 |
+
context: The context to use for validation, this is passed to functional validators as
|
| 181 |
+
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
|
| 182 |
+
self_instance: An instance of a model set attributes on from validation.
|
| 183 |
+
allow_partial: Whether to allow partial validation; if `True` incomplete JSON will be parsed successfully
|
| 184 |
+
and errors in the last element of sequences and mappings are ignored.
|
| 185 |
+
`'trailing-strings'` means any final unfinished JSON string is included in the result.
|
| 186 |
+
by_alias: Whether to use the field's alias when validating against the provided input data.
|
| 187 |
+
by_name: Whether to use the field's name when validating against the provided input data.
|
| 188 |
+
|
| 189 |
+
Raises:
|
| 190 |
+
ValidationError: If validation fails or if the JSON data is invalid.
|
| 191 |
+
Exception: Other error types maybe raised if internal errors occur.
|
| 192 |
+
|
| 193 |
+
Returns:
|
| 194 |
+
The validated Python object.
|
| 195 |
+
"""
|
| 196 |
+
def validate_strings(
|
| 197 |
+
self,
|
| 198 |
+
input: _StringInput,
|
| 199 |
+
*,
|
| 200 |
+
strict: bool | None = None,
|
| 201 |
+
extra: ExtraBehavior | None = None,
|
| 202 |
+
context: Any | None = None,
|
| 203 |
+
allow_partial: bool | Literal['off', 'on', 'trailing-strings'] = False,
|
| 204 |
+
by_alias: bool | None = None,
|
| 205 |
+
by_name: bool | None = None,
|
| 206 |
+
) -> Any:
|
| 207 |
+
"""
|
| 208 |
+
Validate a string against the schema and return the validated Python object.
|
| 209 |
+
|
| 210 |
+
This is similar to `validate_json` but applies to scenarios where the input will be a string but not
|
| 211 |
+
JSON data, e.g. URL fragments, query parameters, etc.
|
| 212 |
+
|
| 213 |
+
Arguments:
|
| 214 |
+
input: The input as a string, or bytes/bytearray if `strict=False`.
|
| 215 |
+
strict: Whether to validate the object in strict mode.
|
| 216 |
+
If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
|
| 217 |
+
extra: Whether to ignore, allow, or forbid extra data during model validation.
|
| 218 |
+
If `None`, the value of [`CoreConfig.extra_fields_behavior`][pydantic_core.core_schema.CoreConfig] is used.
|
| 219 |
+
context: The context to use for validation, this is passed to functional validators as
|
| 220 |
+
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
|
| 221 |
+
allow_partial: Whether to allow partial validation; if `True` errors in the last element of sequences
|
| 222 |
+
and mappings are ignored.
|
| 223 |
+
`'trailing-strings'` means any final unfinished JSON string is included in the result.
|
| 224 |
+
by_alias: Whether to use the field's alias when validating against the provided input data.
|
| 225 |
+
by_name: Whether to use the field's name when validating against the provided input data.
|
| 226 |
+
|
| 227 |
+
Raises:
|
| 228 |
+
ValidationError: If validation fails or if the JSON data is invalid.
|
| 229 |
+
Exception: Other error types maybe raised if internal errors occur.
|
| 230 |
+
|
| 231 |
+
Returns:
|
| 232 |
+
The validated Python object.
|
| 233 |
+
"""
|
| 234 |
+
def validate_assignment(
|
| 235 |
+
self,
|
| 236 |
+
obj: Any,
|
| 237 |
+
field_name: str,
|
| 238 |
+
field_value: Any,
|
| 239 |
+
*,
|
| 240 |
+
strict: bool | None = None,
|
| 241 |
+
extra: ExtraBehavior | None = None,
|
| 242 |
+
from_attributes: bool | None = None,
|
| 243 |
+
context: Any | None = None,
|
| 244 |
+
by_alias: bool | None = None,
|
| 245 |
+
by_name: bool | None = None,
|
| 246 |
+
) -> dict[str, Any] | tuple[dict[str, Any], dict[str, Any] | None, set[str]]:
|
| 247 |
+
"""
|
| 248 |
+
Validate an assignment to a field on a model.
|
| 249 |
+
|
| 250 |
+
Arguments:
|
| 251 |
+
obj: The model instance being assigned to.
|
| 252 |
+
field_name: The name of the field to validate assignment for.
|
| 253 |
+
field_value: The value to assign to the field.
|
| 254 |
+
strict: Whether to validate the object in strict mode.
|
| 255 |
+
If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
|
| 256 |
+
extra: Whether to ignore, allow, or forbid extra data during model validation.
|
| 257 |
+
If `None`, the value of [`CoreConfig.extra_fields_behavior`][pydantic_core.core_schema.CoreConfig] is used.
|
| 258 |
+
from_attributes: Whether to validate objects as inputs to models by extracting attributes.
|
| 259 |
+
If `None`, the value of [`CoreConfig.from_attributes`][pydantic_core.core_schema.CoreConfig] is used.
|
| 260 |
+
context: The context to use for validation, this is passed to functional validators as
|
| 261 |
+
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
|
| 262 |
+
by_alias: Whether to use the field's alias when validating against the provided input data.
|
| 263 |
+
by_name: Whether to use the field's name when validating against the provided input data.
|
| 264 |
+
|
| 265 |
+
Raises:
|
| 266 |
+
ValidationError: If validation fails.
|
| 267 |
+
Exception: Other error types maybe raised if internal errors occur.
|
| 268 |
+
|
| 269 |
+
Returns:
|
| 270 |
+
Either the model dict or a tuple of `(model_data, model_extra, fields_set)`
|
| 271 |
+
"""
|
| 272 |
+
def get_default_value(self, *, strict: bool | None = None, context: Any = None) -> Some | None:
|
| 273 |
+
"""
|
| 274 |
+
Get the default value for the schema, including running default value validation.
|
| 275 |
+
|
| 276 |
+
Arguments:
|
| 277 |
+
strict: Whether to validate the default value in strict mode.
|
| 278 |
+
If `None`, the value of [`CoreConfig.strict`][pydantic_core.core_schema.CoreConfig] is used.
|
| 279 |
+
context: The context to use for validation, this is passed to functional validators as
|
| 280 |
+
[`info.context`][pydantic_core.core_schema.ValidationInfo.context].
|
| 281 |
+
|
| 282 |
+
Raises:
|
| 283 |
+
ValidationError: If validation fails.
|
| 284 |
+
Exception: Other error types maybe raised if internal errors occur.
|
| 285 |
+
|
| 286 |
+
Returns:
|
| 287 |
+
`None` if the schema has no default value, otherwise a [`Some`][pydantic_core.Some] containing the default.
|
| 288 |
+
"""
|
| 289 |
+
|
| 290 |
+
# In reality, `bool` should be replaced by `Literal[True]` but mypy fails to correctly apply bidirectional type inference
|
| 291 |
+
# (e.g. when using `{'a': {'b': True}}`).
|
| 292 |
+
_IncEx: TypeAlias = set[int] | set[str] | Mapping[int, _IncEx | bool] | Mapping[str, _IncEx | bool]
|
| 293 |
+
|
| 294 |
+
@final
|
| 295 |
+
class SchemaSerializer:
|
| 296 |
+
"""
|
| 297 |
+
`SchemaSerializer` is the Python wrapper for `pydantic-core`'s Rust serialization logic, internally it owns one
|
| 298 |
+
`CombinedSerializer` which may in turn own more `CombinedSerializer`s which make up the full schema serializer.
|
| 299 |
+
"""
|
| 300 |
+
|
| 301 |
+
def __init__(self, schema: CoreSchema, config: CoreConfig | None = None, _use_prebuilt: bool = True) -> None:
|
| 302 |
+
"""Initializes the `SchemaSerializer`.
|
| 303 |
+
|
| 304 |
+
Arguments:
|
| 305 |
+
schema: The `CoreSchema` to use for serialization.
|
| 306 |
+
config: Optionally a [`CoreConfig`][pydantic_core.core_schema.CoreConfig] to to configure serialization.
|
| 307 |
+
_use_prebuilt: Whether to use pre-built validators (False during rebuilds to avoid stale references).
|
| 308 |
+
"""
|
| 309 |
+
|
| 310 |
+
def __new__(cls, schema: CoreSchema, config: CoreConfig | None = None, _use_prebuilt: bool = True) -> Self: ...
|
| 311 |
+
def to_python(
|
| 312 |
+
self,
|
| 313 |
+
value: Any,
|
| 314 |
+
*,
|
| 315 |
+
mode: str | None = None,
|
| 316 |
+
include: _IncEx | None = None,
|
| 317 |
+
exclude: _IncEx | None = None,
|
| 318 |
+
by_alias: bool | None = None,
|
| 319 |
+
exclude_unset: bool = False,
|
| 320 |
+
exclude_defaults: bool = False,
|
| 321 |
+
exclude_none: bool = False,
|
| 322 |
+
exclude_computed_fields: bool = False,
|
| 323 |
+
round_trip: bool = False,
|
| 324 |
+
warnings: bool | Literal['none', 'warn', 'error'] = True,
|
| 325 |
+
fallback: Callable[[Any], Any] | None = None,
|
| 326 |
+
serialize_as_any: bool = False,
|
| 327 |
+
polymorphic_serialization: bool | None = None,
|
| 328 |
+
context: Any | None = None,
|
| 329 |
+
) -> Any:
|
| 330 |
+
"""
|
| 331 |
+
Serialize/marshal a Python object to a Python object including transforming and filtering data.
|
| 332 |
+
|
| 333 |
+
Arguments:
|
| 334 |
+
value: The Python object to serialize.
|
| 335 |
+
mode: The serialization mode to use, either `'python'` or `'json'`, defaults to `'python'`. In JSON mode,
|
| 336 |
+
all values are converted to JSON compatible types, e.g. `None`, `int`, `float`, `str`, `list`, `dict`.
|
| 337 |
+
include: A set of fields to include, if `None` all fields are included.
|
| 338 |
+
exclude: A set of fields to exclude, if `None` no fields are excluded.
|
| 339 |
+
by_alias: Whether to use the alias names of fields.
|
| 340 |
+
exclude_unset: Whether to exclude fields that are not set,
|
| 341 |
+
e.g. are not included in `__pydantic_fields_set__`.
|
| 342 |
+
exclude_defaults: Whether to exclude fields that are equal to their default value.
|
| 343 |
+
exclude_none: Whether to exclude fields that have a value of `None`.
|
| 344 |
+
exclude_computed_fields: Whether to exclude computed fields.
|
| 345 |
+
round_trip: Whether to enable serialization and validation round-trip support.
|
| 346 |
+
warnings: How to handle invalid fields. False/"none" ignores them, True/"warn" logs errors,
|
| 347 |
+
"error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].
|
| 348 |
+
fallback: A function to call when an unknown value is encountered,
|
| 349 |
+
if `None` a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.
|
| 350 |
+
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
|
| 351 |
+
polymorphic_serialization: Whether to use model and dataclass polymorphic serialization for this call.
|
| 352 |
+
context: The context to use for serialization, this is passed to functional serializers as
|
| 353 |
+
[`info.context`][pydantic_core.core_schema.SerializationInfo.context].
|
| 354 |
+
|
| 355 |
+
Raises:
|
| 356 |
+
PydanticSerializationError: If serialization fails and no `fallback` function is provided.
|
| 357 |
+
|
| 358 |
+
Returns:
|
| 359 |
+
The serialized Python object.
|
| 360 |
+
"""
|
| 361 |
+
def to_json(
|
| 362 |
+
self,
|
| 363 |
+
value: Any,
|
| 364 |
+
*,
|
| 365 |
+
indent: int | None = None,
|
| 366 |
+
ensure_ascii: bool = False,
|
| 367 |
+
include: _IncEx | None = None,
|
| 368 |
+
exclude: _IncEx | None = None,
|
| 369 |
+
by_alias: bool | None = None,
|
| 370 |
+
exclude_unset: bool = False,
|
| 371 |
+
exclude_defaults: bool = False,
|
| 372 |
+
exclude_none: bool = False,
|
| 373 |
+
exclude_computed_fields: bool = False,
|
| 374 |
+
round_trip: bool = False,
|
| 375 |
+
warnings: bool | Literal['none', 'warn', 'error'] = True,
|
| 376 |
+
fallback: Callable[[Any], Any] | None = None,
|
| 377 |
+
serialize_as_any: bool = False,
|
| 378 |
+
polymorphic_serialization: bool | None = None,
|
| 379 |
+
context: Any | None = None,
|
| 380 |
+
) -> bytes:
|
| 381 |
+
"""
|
| 382 |
+
Serialize a Python object to JSON including transforming and filtering data.
|
| 383 |
+
|
| 384 |
+
Arguments:
|
| 385 |
+
value: The Python object to serialize.
|
| 386 |
+
indent: If `None`, the JSON will be compact, otherwise it will be pretty-printed with the indent provided.
|
| 387 |
+
ensure_ascii: If `True`, the output is guaranteed to have all incoming non-ASCII characters escaped.
|
| 388 |
+
If `False` (the default), these characters will be output as-is.
|
| 389 |
+
include: A set of fields to include, if `None` all fields are included.
|
| 390 |
+
exclude: A set of fields to exclude, if `None` no fields are excluded.
|
| 391 |
+
by_alias: Whether to use the alias names of fields.
|
| 392 |
+
exclude_unset: Whether to exclude fields that are not set,
|
| 393 |
+
e.g. are not included in `__pydantic_fields_set__`.
|
| 394 |
+
exclude_defaults: Whether to exclude fields that are equal to their default value.
|
| 395 |
+
exclude_none: Whether to exclude fields that have a value of `None`.
|
| 396 |
+
exclude_computed_fields: Whether to exclude computed fields.
|
| 397 |
+
round_trip: Whether to enable serialization and validation round-trip support.
|
| 398 |
+
warnings: How to handle invalid fields. False/"none" ignores them, True/"warn" logs errors,
|
| 399 |
+
"error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].
|
| 400 |
+
fallback: A function to call when an unknown value is encountered,
|
| 401 |
+
if `None` a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.
|
| 402 |
+
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
|
| 403 |
+
polymorphic_serialization: Whether to use model and dataclass polymorphic serialization for this call.
|
| 404 |
+
context: The context to use for serialization, this is passed to functional serializers as
|
| 405 |
+
[`info.context`][pydantic_core.core_schema.SerializationInfo.context].
|
| 406 |
+
|
| 407 |
+
Raises:
|
| 408 |
+
PydanticSerializationError: If serialization fails and no `fallback` function is provided.
|
| 409 |
+
|
| 410 |
+
Returns:
|
| 411 |
+
JSON bytes.
|
| 412 |
+
"""
|
| 413 |
+
|
| 414 |
+
def to_json(
|
| 415 |
+
value: Any,
|
| 416 |
+
*,
|
| 417 |
+
indent: int | None = None,
|
| 418 |
+
ensure_ascii: bool = False,
|
| 419 |
+
include: _IncEx | None = None,
|
| 420 |
+
exclude: _IncEx | None = None,
|
| 421 |
+
# Note: In Pydantic 2.11, the default value of `by_alias` on `SchemaSerializer` was changed from `True` to `None`,
|
| 422 |
+
# to be consistent with the Pydantic "dump" methods. However, the default of `True` was kept here for
|
| 423 |
+
# backwards compatibility. In Pydantic V3, `by_alias` is expected to default to `True` everywhere:
|
| 424 |
+
by_alias: bool = True,
|
| 425 |
+
exclude_none: bool = False,
|
| 426 |
+
round_trip: bool = False,
|
| 427 |
+
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
|
| 428 |
+
temporal_mode: Literal['iso8601', 'seconds', 'milliseconds'] = 'iso8601',
|
| 429 |
+
bytes_mode: Literal['utf8', 'base64', 'hex'] = 'utf8',
|
| 430 |
+
inf_nan_mode: Literal['null', 'constants', 'strings'] = 'constants',
|
| 431 |
+
serialize_unknown: bool = False,
|
| 432 |
+
fallback: Callable[[Any], Any] | None = None,
|
| 433 |
+
serialize_as_any: bool = False,
|
| 434 |
+
polymorphic_serialization: bool | None = None,
|
| 435 |
+
context: Any | None = None,
|
| 436 |
+
) -> bytes:
|
| 437 |
+
"""
|
| 438 |
+
Serialize a Python object to JSON including transforming and filtering data.
|
| 439 |
+
|
| 440 |
+
This is effectively a standalone version of [`SchemaSerializer.to_json`][pydantic_core.SchemaSerializer.to_json].
|
| 441 |
+
|
| 442 |
+
Arguments:
|
| 443 |
+
value: The Python object to serialize.
|
| 444 |
+
indent: If `None`, the JSON will be compact, otherwise it will be pretty-printed with the indent provided.
|
| 445 |
+
ensure_ascii: If `True`, the output is guaranteed to have all incoming non-ASCII characters escaped.
|
| 446 |
+
If `False` (the default), these characters will be output as-is.
|
| 447 |
+
include: A set of fields to include, if `None` all fields are included.
|
| 448 |
+
exclude: A set of fields to exclude, if `None` no fields are excluded.
|
| 449 |
+
by_alias: Whether to use the alias names of fields.
|
| 450 |
+
exclude_none: Whether to exclude fields that have a value of `None`.
|
| 451 |
+
round_trip: Whether to enable serialization and validation round-trip support.
|
| 452 |
+
timedelta_mode: How to serialize `timedelta` objects, either `'iso8601'` or `'float'`.
|
| 453 |
+
temporal_mode: How to serialize datetime-like objects (`datetime`, `date`, `time`), either `'iso8601'`, `'seconds'`, or `'milliseconds'`.
|
| 454 |
+
`iso8601` returns an ISO 8601 string; `seconds` returns the Unix timestamp in seconds as a float; `milliseconds` returns the Unix timestamp in milliseconds as a float.
|
| 455 |
+
|
| 456 |
+
bytes_mode: How to serialize `bytes` objects, either `'utf8'`, `'base64'`, or `'hex'`.
|
| 457 |
+
inf_nan_mode: How to serialize `Infinity`, `-Infinity` and `NaN` values, either `'null'`, `'constants'`, or `'strings'`.
|
| 458 |
+
serialize_unknown: Attempt to serialize unknown types, `str(value)` will be used, if that fails
|
| 459 |
+
`"<Unserializable {value_type} object>"` will be used.
|
| 460 |
+
fallback: A function to call when an unknown value is encountered,
|
| 461 |
+
if `None` a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.
|
| 462 |
+
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
|
| 463 |
+
polymorphic_serialization: Whether to use model and dataclass polymorphic serialization for this call.
|
| 464 |
+
context: The context to use for serialization, this is passed to functional serializers as
|
| 465 |
+
[`info.context`][pydantic_core.core_schema.SerializationInfo.context].
|
| 466 |
+
|
| 467 |
+
Raises:
|
| 468 |
+
PydanticSerializationError: If serialization fails and no `fallback` function is provided.
|
| 469 |
+
|
| 470 |
+
Returns:
|
| 471 |
+
JSON bytes.
|
| 472 |
+
"""
|
| 473 |
+
|
| 474 |
+
def from_json(
|
| 475 |
+
data: str | bytes | bytearray,
|
| 476 |
+
*,
|
| 477 |
+
allow_inf_nan: bool = True,
|
| 478 |
+
cache_strings: bool | Literal['all', 'keys', 'none'] = True,
|
| 479 |
+
allow_partial: bool | Literal['off', 'on', 'trailing-strings'] = False,
|
| 480 |
+
) -> Any:
|
| 481 |
+
"""
|
| 482 |
+
Deserialize JSON data to a Python object.
|
| 483 |
+
|
| 484 |
+
This is effectively a faster version of `json.loads()`, with some extra functionality.
|
| 485 |
+
|
| 486 |
+
Arguments:
|
| 487 |
+
data: The JSON data to deserialize.
|
| 488 |
+
allow_inf_nan: Whether to allow `Infinity`, `-Infinity` and `NaN` values as `json.loads()` does by default.
|
| 489 |
+
cache_strings: Whether to cache strings to avoid constructing new Python objects,
|
| 490 |
+
this should have a significant impact on performance while increasing memory usage slightly,
|
| 491 |
+
`all/True` means cache all strings, `keys` means cache only dict keys, `none/False` means no caching.
|
| 492 |
+
allow_partial: Whether to allow partial deserialization, if `True` JSON data is returned if the end of the
|
| 493 |
+
input is reached before the full object is deserialized, e.g. `["aa", "bb", "c` would return `['aa', 'bb']`.
|
| 494 |
+
`'trailing-strings'` means any final unfinished JSON string is included in the result.
|
| 495 |
+
|
| 496 |
+
Raises:
|
| 497 |
+
ValueError: If deserialization fails.
|
| 498 |
+
|
| 499 |
+
Returns:
|
| 500 |
+
The deserialized Python object.
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
def to_jsonable_python(
|
| 504 |
+
value: Any,
|
| 505 |
+
*,
|
| 506 |
+
include: _IncEx | None = None,
|
| 507 |
+
exclude: _IncEx | None = None,
|
| 508 |
+
# Note: In Pydantic 2.11, the default value of `by_alias` on `SchemaSerializer` was changed from `True` to `None`,
|
| 509 |
+
# to be consistent with the Pydantic "dump" methods. However, the default of `True` was kept here for
|
| 510 |
+
# backwards compatibility. In Pydantic V3, `by_alias` is expected to default to `True` everywhere:
|
| 511 |
+
by_alias: bool = True,
|
| 512 |
+
exclude_none: bool = False,
|
| 513 |
+
round_trip: bool = False,
|
| 514 |
+
timedelta_mode: Literal['iso8601', 'float'] = 'iso8601',
|
| 515 |
+
temporal_mode: Literal['iso8601', 'seconds', 'milliseconds'] = 'iso8601',
|
| 516 |
+
bytes_mode: Literal['utf8', 'base64', 'hex'] = 'utf8',
|
| 517 |
+
inf_nan_mode: Literal['null', 'constants', 'strings'] = 'constants',
|
| 518 |
+
serialize_unknown: bool = False,
|
| 519 |
+
fallback: Callable[[Any], Any] | None = None,
|
| 520 |
+
serialize_as_any: bool = False,
|
| 521 |
+
polymorphic_serialization: bool | None = None,
|
| 522 |
+
context: Any | None = None,
|
| 523 |
+
) -> Any:
|
| 524 |
+
"""
|
| 525 |
+
Serialize/marshal a Python object to a JSON-serializable Python object including transforming and filtering data.
|
| 526 |
+
|
| 527 |
+
This is effectively a standalone version of
|
| 528 |
+
[`SchemaSerializer.to_python(mode='json')`][pydantic_core.SchemaSerializer.to_python].
|
| 529 |
+
|
| 530 |
+
Args:
|
| 531 |
+
value: The Python object to serialize.
|
| 532 |
+
include: A set of fields to include, if `None` all fields are included.
|
| 533 |
+
exclude: A set of fields to exclude, if `None` no fields are excluded.
|
| 534 |
+
by_alias: Whether to use the alias names of fields.
|
| 535 |
+
exclude_none: Whether to exclude fields that have a value of `None`.
|
| 536 |
+
round_trip: Whether to enable serialization and validation round-trip support.
|
| 537 |
+
timedelta_mode: How to serialize `timedelta` objects, either `'iso8601'` or `'float'`.
|
| 538 |
+
temporal_mode: How to serialize datetime-like objects (`datetime`, `date`, `time`), either `'iso8601'`, `'seconds'`, or `'milliseconds'`.
|
| 539 |
+
`iso8601` returns an ISO 8601 string; `seconds` returns the Unix timestamp in seconds as a float; `milliseconds` returns the Unix timestamp in milliseconds as a float.
|
| 540 |
+
|
| 541 |
+
bytes_mode: How to serialize `bytes` objects, either `'utf8'`, `'base64'`, or `'hex'`.
|
| 542 |
+
inf_nan_mode: How to serialize `Infinity`, `-Infinity` and `NaN` values, either `'null'`, `'constants'`, or `'strings'`.
|
| 543 |
+
serialize_unknown: Attempt to serialize unknown types, `str(value)` will be used, if that fails
|
| 544 |
+
`"<Unserializable {value_type} object>"` will be used.
|
| 545 |
+
fallback: A function to call when an unknown value is encountered,
|
| 546 |
+
if `None` a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.
|
| 547 |
+
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
|
| 548 |
+
polymorphic_serialization: Whether to use model and dataclass polymorphic serialization for this call.
|
| 549 |
+
context: The context to use for serialization, this is passed to functional serializers as
|
| 550 |
+
[`info.context`][pydantic_core.core_schema.SerializationInfo.context].
|
| 551 |
+
|
| 552 |
+
Raises:
|
| 553 |
+
PydanticSerializationError: If serialization fails and no `fallback` function is provided.
|
| 554 |
+
|
| 555 |
+
Returns:
|
| 556 |
+
The serialized Python object.
|
| 557 |
+
"""
|
| 558 |
+
|
| 559 |
+
class Url(SupportsAllComparisons):
|
| 560 |
+
"""
|
| 561 |
+
A URL type, internal logic uses the [url rust crate](https://docs.rs/url/latest/url/) originally developed
|
| 562 |
+
by Mozilla.
|
| 563 |
+
"""
|
| 564 |
+
|
| 565 |
+
def __init__(self, url: str) -> None: ...
|
| 566 |
+
def __new__(cls, url: str) -> Self: ...
|
| 567 |
+
@property
|
| 568 |
+
def scheme(self) -> str: ...
|
| 569 |
+
@property
|
| 570 |
+
def username(self) -> str | None: ...
|
| 571 |
+
@property
|
| 572 |
+
def password(self) -> str | None: ...
|
| 573 |
+
@property
|
| 574 |
+
def host(self) -> str | None: ...
|
| 575 |
+
def unicode_host(self) -> str | None: ...
|
| 576 |
+
@property
|
| 577 |
+
def port(self) -> int | None: ...
|
| 578 |
+
@property
|
| 579 |
+
def path(self) -> str | None: ...
|
| 580 |
+
@property
|
| 581 |
+
def query(self) -> str | None: ...
|
| 582 |
+
def query_params(self) -> list[tuple[str, str]]: ...
|
| 583 |
+
@property
|
| 584 |
+
def fragment(self) -> str | None: ...
|
| 585 |
+
def unicode_string(self) -> str: ...
|
| 586 |
+
def __repr__(self) -> str: ...
|
| 587 |
+
def __str__(self) -> str: ...
|
| 588 |
+
def __deepcopy__(self, memo: dict) -> str: ...
|
| 589 |
+
@classmethod
|
| 590 |
+
def build(
|
| 591 |
+
cls,
|
| 592 |
+
*,
|
| 593 |
+
scheme: str,
|
| 594 |
+
username: str | None = None,
|
| 595 |
+
password: str | None = None,
|
| 596 |
+
host: str,
|
| 597 |
+
port: int | None = None,
|
| 598 |
+
path: str | None = None,
|
| 599 |
+
query: str | None = None,
|
| 600 |
+
fragment: str | None = None,
|
| 601 |
+
) -> Self: ...
|
| 602 |
+
|
| 603 |
+
class MultiHostUrl(SupportsAllComparisons):
|
| 604 |
+
"""
|
| 605 |
+
A URL type with support for multiple hosts, as used by some databases for DSNs, e.g. `https://foo.com,bar.com/path`.
|
| 606 |
+
|
| 607 |
+
Internal URL logic uses the [url rust crate](https://docs.rs/url/latest/url/) originally developed
|
| 608 |
+
by Mozilla.
|
| 609 |
+
"""
|
| 610 |
+
|
| 611 |
+
def __init__(self, url: str) -> None: ...
|
| 612 |
+
def __new__(cls, url: str) -> Self: ...
|
| 613 |
+
@property
|
| 614 |
+
def scheme(self) -> str: ...
|
| 615 |
+
@property
|
| 616 |
+
def path(self) -> str | None: ...
|
| 617 |
+
@property
|
| 618 |
+
def query(self) -> str | None: ...
|
| 619 |
+
def query_params(self) -> list[tuple[str, str]]: ...
|
| 620 |
+
@property
|
| 621 |
+
def fragment(self) -> str | None: ...
|
| 622 |
+
def hosts(self) -> list[MultiHostHost]: ...
|
| 623 |
+
def unicode_string(self) -> str: ...
|
| 624 |
+
def __repr__(self) -> str: ...
|
| 625 |
+
def __str__(self) -> str: ...
|
| 626 |
+
def __deepcopy__(self, memo: dict) -> Self: ...
|
| 627 |
+
@classmethod
|
| 628 |
+
def build(
|
| 629 |
+
cls,
|
| 630 |
+
*,
|
| 631 |
+
scheme: str,
|
| 632 |
+
hosts: list[MultiHostHost] | None = None,
|
| 633 |
+
username: str | None = None,
|
| 634 |
+
password: str | None = None,
|
| 635 |
+
host: str | None = None,
|
| 636 |
+
port: int | None = None,
|
| 637 |
+
path: str | None = None,
|
| 638 |
+
query: str | None = None,
|
| 639 |
+
fragment: str | None = None,
|
| 640 |
+
) -> Self: ...
|
| 641 |
+
|
| 642 |
+
@final
|
| 643 |
+
class SchemaError(Exception):
|
| 644 |
+
"""
|
| 645 |
+
Information about errors that occur while building a [`SchemaValidator`][pydantic_core.SchemaValidator]
|
| 646 |
+
or [`SchemaSerializer`][pydantic_core.SchemaSerializer].
|
| 647 |
+
"""
|
| 648 |
+
|
| 649 |
+
def error_count(self) -> int:
|
| 650 |
+
"""
|
| 651 |
+
Returns:
|
| 652 |
+
The number of errors in the schema.
|
| 653 |
+
"""
|
| 654 |
+
def errors(self) -> list[ErrorDetails]:
|
| 655 |
+
"""
|
| 656 |
+
Returns:
|
| 657 |
+
A list of [`ErrorDetails`][pydantic_core.ErrorDetails] for each error in the schema.
|
| 658 |
+
"""
|
| 659 |
+
|
| 660 |
+
class ValidationError(ValueError):
|
| 661 |
+
"""
|
| 662 |
+
`ValidationError` is the exception raised by `pydantic-core` when validation fails, it contains a list of errors
|
| 663 |
+
which detail why validation failed.
|
| 664 |
+
"""
|
| 665 |
+
@classmethod
|
| 666 |
+
def from_exception_data(
|
| 667 |
+
cls,
|
| 668 |
+
title: str,
|
| 669 |
+
line_errors: list[InitErrorDetails],
|
| 670 |
+
input_type: Literal['python', 'json'] = 'python',
|
| 671 |
+
hide_input: bool = False,
|
| 672 |
+
) -> Self:
|
| 673 |
+
"""
|
| 674 |
+
Python constructor for a Validation Error.
|
| 675 |
+
|
| 676 |
+
Arguments:
|
| 677 |
+
title: The title of the error, as used in the heading of `str(validation_error)`
|
| 678 |
+
line_errors: A list of [`InitErrorDetails`][pydantic_core.InitErrorDetails] which contain information
|
| 679 |
+
about errors that occurred during validation.
|
| 680 |
+
input_type: Whether the error is for a Python object or JSON.
|
| 681 |
+
hide_input: Whether to hide the input value in the error message.
|
| 682 |
+
"""
|
| 683 |
+
@property
|
| 684 |
+
def title(self) -> str:
|
| 685 |
+
"""
|
| 686 |
+
The title of the error, as used in the heading of `str(validation_error)`.
|
| 687 |
+
"""
|
| 688 |
+
def error_count(self) -> int:
|
| 689 |
+
"""
|
| 690 |
+
Returns:
|
| 691 |
+
The number of errors in the validation error.
|
| 692 |
+
"""
|
| 693 |
+
def errors(
|
| 694 |
+
self, *, include_url: bool = True, include_context: bool = True, include_input: bool = True
|
| 695 |
+
) -> list[ErrorDetails]:
|
| 696 |
+
"""
|
| 697 |
+
Details about each error in the validation error.
|
| 698 |
+
|
| 699 |
+
Args:
|
| 700 |
+
include_url: Whether to include a URL to documentation on the error each error.
|
| 701 |
+
include_context: Whether to include the context of each error.
|
| 702 |
+
include_input: Whether to include the input value of each error.
|
| 703 |
+
|
| 704 |
+
Returns:
|
| 705 |
+
A list of [`ErrorDetails`][pydantic_core.ErrorDetails] for each error in the validation error.
|
| 706 |
+
"""
|
| 707 |
+
def json(
|
| 708 |
+
self,
|
| 709 |
+
*,
|
| 710 |
+
indent: int | None = None,
|
| 711 |
+
include_url: bool = True,
|
| 712 |
+
include_context: bool = True,
|
| 713 |
+
include_input: bool = True,
|
| 714 |
+
) -> str:
|
| 715 |
+
"""
|
| 716 |
+
Same as [`errors()`][pydantic_core.ValidationError.errors] but returns a JSON string.
|
| 717 |
+
|
| 718 |
+
Args:
|
| 719 |
+
indent: The number of spaces to indent the JSON by, or `None` for no indentation - compact JSON.
|
| 720 |
+
include_url: Whether to include a URL to documentation on the error each error.
|
| 721 |
+
include_context: Whether to include the context of each error.
|
| 722 |
+
include_input: Whether to include the input value of each error.
|
| 723 |
+
|
| 724 |
+
Returns:
|
| 725 |
+
a JSON string.
|
| 726 |
+
"""
|
| 727 |
+
|
| 728 |
+
def __repr__(self) -> str:
|
| 729 |
+
"""
|
| 730 |
+
A string representation of the validation error.
|
| 731 |
+
|
| 732 |
+
Whether or not documentation URLs are included in the repr is controlled by the
|
| 733 |
+
environment variable `PYDANTIC_ERRORS_INCLUDE_URL` being set to `1` or
|
| 734 |
+
`true`; by default, URLs are shown.
|
| 735 |
+
|
| 736 |
+
Due to implementation details, this environment variable can only be set once,
|
| 737 |
+
before the first validation error is created.
|
| 738 |
+
"""
|
| 739 |
+
|
| 740 |
+
class PydanticCustomError(ValueError):
|
| 741 |
+
"""A custom exception providing flexible error handling for Pydantic validators.
|
| 742 |
+
|
| 743 |
+
You can raise this error in custom validators when you'd like flexibility in regards to the error type, message, and context.
|
| 744 |
+
|
| 745 |
+
Example:
|
| 746 |
+
```py
|
| 747 |
+
from pydantic_core import PydanticCustomError
|
| 748 |
+
|
| 749 |
+
def custom_validator(v) -> None:
|
| 750 |
+
if v <= 10:
|
| 751 |
+
raise PydanticCustomError('custom_value_error', 'Value must be greater than {value}', {'value': 10, 'extra_context': 'extra_data'})
|
| 752 |
+
return v
|
| 753 |
+
```
|
| 754 |
+
|
| 755 |
+
Arguments:
|
| 756 |
+
error_type: The error type.
|
| 757 |
+
message_template: The message template.
|
| 758 |
+
context: The data to inject into the message template.
|
| 759 |
+
"""
|
| 760 |
+
|
| 761 |
+
def __init__(
|
| 762 |
+
self, error_type: LiteralString, message_template: LiteralString, context: dict[str, Any] | None = None, /
|
| 763 |
+
) -> None: ...
|
| 764 |
+
@property
|
| 765 |
+
def context(self) -> dict[str, Any] | None:
|
| 766 |
+
"""Values which are required to render the error message, and could hence be useful in passing error data forward."""
|
| 767 |
+
|
| 768 |
+
@property
|
| 769 |
+
def type(self) -> str:
|
| 770 |
+
"""The error type associated with the error. For consistency with Pydantic, this is typically a snake_case string."""
|
| 771 |
+
|
| 772 |
+
@property
|
| 773 |
+
def message_template(self) -> str:
|
| 774 |
+
"""The message template associated with the error. This is a string that can be formatted with context variables in `{curly_braces}`."""
|
| 775 |
+
|
| 776 |
+
def message(self) -> str:
|
| 777 |
+
"""The formatted message associated with the error. This presents as the message template with context variables appropriately injected."""
|
| 778 |
+
|
| 779 |
+
@final
|
| 780 |
+
class PydanticKnownError(ValueError):
|
| 781 |
+
"""A helper class for raising exceptions that mimic Pydantic's built-in exceptions, with more flexibility in regards to context.
|
| 782 |
+
|
| 783 |
+
Unlike [`PydanticCustomError`][pydantic_core.PydanticCustomError], the `error_type` argument must be a known `ErrorType`.
|
| 784 |
+
|
| 785 |
+
Example:
|
| 786 |
+
```py
|
| 787 |
+
from pydantic_core import PydanticKnownError
|
| 788 |
+
|
| 789 |
+
def custom_validator(v) -> None:
|
| 790 |
+
if v <= 10:
|
| 791 |
+
raise PydanticKnownError('greater_than', {'gt': 10})
|
| 792 |
+
return v
|
| 793 |
+
```
|
| 794 |
+
|
| 795 |
+
Arguments:
|
| 796 |
+
error_type: The error type.
|
| 797 |
+
context: The data to inject into the message template.
|
| 798 |
+
"""
|
| 799 |
+
|
| 800 |
+
def __init__(self, error_type: ErrorType, context: dict[str, Any] | None = None, /) -> None: ...
|
| 801 |
+
@property
|
| 802 |
+
def context(self) -> dict[str, Any] | None:
|
| 803 |
+
"""Values which are required to render the error message, and could hence be useful in passing error data forward."""
|
| 804 |
+
|
| 805 |
+
@property
|
| 806 |
+
def type(self) -> ErrorType:
|
| 807 |
+
"""The type of the error."""
|
| 808 |
+
|
| 809 |
+
@property
|
| 810 |
+
def message_template(self) -> str:
|
| 811 |
+
"""The message template associated with the provided error type. This is a string that can be formatted with context variables in `{curly_braces}`."""
|
| 812 |
+
|
| 813 |
+
def message(self) -> str:
|
| 814 |
+
"""The formatted message associated with the error. This presents as the message template with context variables appropriately injected."""
|
| 815 |
+
|
| 816 |
+
@final
|
| 817 |
+
class PydanticOmit(Exception):
|
| 818 |
+
"""An exception to signal that a field should be omitted from a generated result.
|
| 819 |
+
|
| 820 |
+
This could span from omitting a field from a JSON Schema to omitting a field from a serialized result.
|
| 821 |
+
Upcoming: more robust support for using PydanticOmit in custom serializers is still in development.
|
| 822 |
+
Right now, this is primarily used in the JSON Schema generation process.
|
| 823 |
+
|
| 824 |
+
Example:
|
| 825 |
+
```py
|
| 826 |
+
from typing import Callable
|
| 827 |
+
|
| 828 |
+
from pydantic_core import PydanticOmit
|
| 829 |
+
|
| 830 |
+
from pydantic import BaseModel
|
| 831 |
+
from pydantic.json_schema import GenerateJsonSchema, JsonSchemaValue
|
| 832 |
+
|
| 833 |
+
|
| 834 |
+
class MyGenerateJsonSchema(GenerateJsonSchema):
|
| 835 |
+
def handle_invalid_for_json_schema(self, schema, error_info) -> JsonSchemaValue:
|
| 836 |
+
raise PydanticOmit
|
| 837 |
+
|
| 838 |
+
|
| 839 |
+
class Predicate(BaseModel):
|
| 840 |
+
name: str = 'no-op'
|
| 841 |
+
func: Callable = lambda x: x
|
| 842 |
+
|
| 843 |
+
|
| 844 |
+
instance_example = Predicate()
|
| 845 |
+
|
| 846 |
+
validation_schema = instance_example.model_json_schema(schema_generator=MyGenerateJsonSchema, mode='validation')
|
| 847 |
+
print(validation_schema)
|
| 848 |
+
'''
|
| 849 |
+
{'properties': {'name': {'default': 'no-op', 'title': 'Name', 'type': 'string'}}, 'title': 'Predicate', 'type': 'object'}
|
| 850 |
+
'''
|
| 851 |
+
```
|
| 852 |
+
|
| 853 |
+
For a more in depth example / explanation, see the [customizing JSON schema](../concepts/json_schema.md#customizing-the-json-schema-generation-process) docs.
|
| 854 |
+
"""
|
| 855 |
+
|
| 856 |
+
def __new__(cls) -> Self: ...
|
| 857 |
+
|
| 858 |
+
@final
|
| 859 |
+
class PydanticUseDefault(Exception):
|
| 860 |
+
"""An exception to signal that standard validation either failed or should be skipped, and the default value should be used instead.
|
| 861 |
+
|
| 862 |
+
This warning can be raised in custom validation functions to redirect the flow of validation.
|
| 863 |
+
|
| 864 |
+
Example:
|
| 865 |
+
```py
|
| 866 |
+
from pydantic_core import PydanticUseDefault
|
| 867 |
+
from datetime import datetime
|
| 868 |
+
from pydantic import BaseModel, field_validator
|
| 869 |
+
|
| 870 |
+
|
| 871 |
+
class Event(BaseModel):
|
| 872 |
+
name: str = 'meeting'
|
| 873 |
+
time: datetime
|
| 874 |
+
|
| 875 |
+
@field_validator('name', mode='plain')
|
| 876 |
+
def name_must_be_present(cls, v) -> str:
|
| 877 |
+
if not v or not isinstance(v, str):
|
| 878 |
+
raise PydanticUseDefault()
|
| 879 |
+
return v
|
| 880 |
+
|
| 881 |
+
|
| 882 |
+
event1 = Event(name='party', time=datetime(2024, 1, 1, 12, 0, 0))
|
| 883 |
+
print(repr(event1))
|
| 884 |
+
# > Event(name='party', time=datetime.datetime(2024, 1, 1, 12, 0))
|
| 885 |
+
event2 = Event(time=datetime(2024, 1, 1, 12, 0, 0))
|
| 886 |
+
print(repr(event2))
|
| 887 |
+
# > Event(name='meeting', time=datetime.datetime(2024, 1, 1, 12, 0))
|
| 888 |
+
```
|
| 889 |
+
|
| 890 |
+
For an additional example, see the [validating partial json data](../concepts/json.md#partial-json-parsing) section of the Pydantic documentation.
|
| 891 |
+
"""
|
| 892 |
+
|
| 893 |
+
def __new__(cls) -> Self: ...
|
| 894 |
+
|
| 895 |
+
@final
|
| 896 |
+
class PydanticSerializationError(ValueError):
|
| 897 |
+
"""An error raised when an issue occurs during serialization.
|
| 898 |
+
|
| 899 |
+
In custom serializers, this error can be used to indicate that serialization has failed.
|
| 900 |
+
|
| 901 |
+
Arguments:
|
| 902 |
+
message: The message associated with the error.
|
| 903 |
+
"""
|
| 904 |
+
|
| 905 |
+
def __init__(self, message: str, /) -> None: ...
|
| 906 |
+
|
| 907 |
+
@final
|
| 908 |
+
class PydanticSerializationUnexpectedValue(ValueError):
|
| 909 |
+
"""An error raised when an unexpected value is encountered during serialization.
|
| 910 |
+
|
| 911 |
+
This error is often caught and coerced into a warning, as `pydantic-core` generally makes a best attempt
|
| 912 |
+
at serializing values, in contrast with validation where errors are eagerly raised.
|
| 913 |
+
|
| 914 |
+
Example:
|
| 915 |
+
```py
|
| 916 |
+
from pydantic import BaseModel, field_serializer
|
| 917 |
+
from pydantic_core import PydanticSerializationUnexpectedValue
|
| 918 |
+
|
| 919 |
+
class BasicPoint(BaseModel):
|
| 920 |
+
x: int
|
| 921 |
+
y: int
|
| 922 |
+
|
| 923 |
+
@field_serializer('*')
|
| 924 |
+
def serialize(self, v):
|
| 925 |
+
if not isinstance(v, int):
|
| 926 |
+
raise PydanticSerializationUnexpectedValue(f'Expected type `int`, got {type(v)} with value {v}')
|
| 927 |
+
return v
|
| 928 |
+
|
| 929 |
+
point = BasicPoint(x=1, y=2)
|
| 930 |
+
# some sort of mutation
|
| 931 |
+
point.x = 'a'
|
| 932 |
+
|
| 933 |
+
print(point.model_dump())
|
| 934 |
+
'''
|
| 935 |
+
UserWarning: Pydantic serializer warnings:
|
| 936 |
+
PydanticSerializationUnexpectedValue(Expected type `int`, got <class 'str'> with value a)
|
| 937 |
+
return self.__pydantic_serializer__.to_python(
|
| 938 |
+
{'x': 'a', 'y': 2}
|
| 939 |
+
'''
|
| 940 |
+
```
|
| 941 |
+
|
| 942 |
+
This is often used internally in `pydantic-core` when unexpected types are encountered during serialization,
|
| 943 |
+
but it can also be used by users in custom serializers, as seen above.
|
| 944 |
+
|
| 945 |
+
Arguments:
|
| 946 |
+
message: The message associated with the unexpected value.
|
| 947 |
+
"""
|
| 948 |
+
|
| 949 |
+
def __init__(self, message: str, /) -> None: ...
|
| 950 |
+
|
| 951 |
+
@final
|
| 952 |
+
class ArgsKwargs:
|
| 953 |
+
"""A construct used to store arguments and keyword arguments for a function call.
|
| 954 |
+
|
| 955 |
+
This data structure is generally used to store information for core schemas associated with functions (like in an arguments schema).
|
| 956 |
+
This data structure is also currently used for some validation against dataclasses.
|
| 957 |
+
|
| 958 |
+
Example:
|
| 959 |
+
```py
|
| 960 |
+
from pydantic.dataclasses import dataclass
|
| 961 |
+
from pydantic import model_validator
|
| 962 |
+
|
| 963 |
+
|
| 964 |
+
@dataclass
|
| 965 |
+
class Model:
|
| 966 |
+
a: int
|
| 967 |
+
b: int
|
| 968 |
+
|
| 969 |
+
@model_validator(mode="before")
|
| 970 |
+
@classmethod
|
| 971 |
+
def no_op_validator(cls, values):
|
| 972 |
+
print(values)
|
| 973 |
+
return values
|
| 974 |
+
|
| 975 |
+
Model(1, b=2)
|
| 976 |
+
#> ArgsKwargs((1,), {"b": 2})
|
| 977 |
+
|
| 978 |
+
Model(1, 2)
|
| 979 |
+
#> ArgsKwargs((1, 2), {})
|
| 980 |
+
|
| 981 |
+
Model(a=1, b=2)
|
| 982 |
+
#> ArgsKwargs((), {"a": 1, "b": 2})
|
| 983 |
+
```
|
| 984 |
+
"""
|
| 985 |
+
|
| 986 |
+
def __init__(self, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> None:
|
| 987 |
+
"""Initializes the `ArgsKwargs`.
|
| 988 |
+
|
| 989 |
+
Arguments:
|
| 990 |
+
args: The arguments (inherently ordered) for a function call.
|
| 991 |
+
kwargs: The keyword arguments for a function call
|
| 992 |
+
"""
|
| 993 |
+
|
| 994 |
+
def __new__(cls, args: tuple[Any, ...], kwargs: dict[str, Any] | None = None) -> Self: ...
|
| 995 |
+
@property
|
| 996 |
+
def args(self) -> tuple[Any, ...]:
|
| 997 |
+
"""The arguments (inherently ordered) for a function call."""
|
| 998 |
+
|
| 999 |
+
@property
|
| 1000 |
+
def kwargs(self) -> dict[str, Any] | None:
|
| 1001 |
+
"""The keyword arguments for a function call."""
|
| 1002 |
+
|
| 1003 |
+
@final
|
| 1004 |
+
class PydanticUndefinedType:
|
| 1005 |
+
"""A type used as a sentinel for undefined values."""
|
| 1006 |
+
|
| 1007 |
+
def __copy__(self) -> Self: ...
|
| 1008 |
+
def __deepcopy__(self, memo: Any) -> Self: ...
|
| 1009 |
+
|
| 1010 |
+
PydanticUndefined: PydanticUndefinedType
|
| 1011 |
+
|
| 1012 |
+
def list_all_errors() -> list[ErrorTypeInfo]:
|
| 1013 |
+
"""
|
| 1014 |
+
Get information about all built-in errors.
|
| 1015 |
+
|
| 1016 |
+
Returns:
|
| 1017 |
+
A list of `ErrorTypeInfo` typed dicts.
|
| 1018 |
+
"""
|
| 1019 |
+
@final
|
| 1020 |
+
class TzInfo(datetime.tzinfo):
|
| 1021 |
+
"""An `pydantic-core` implementation of the abstract [`datetime.tzinfo`][] class."""
|
| 1022 |
+
|
| 1023 |
+
def __init__(self, seconds: float = 0.0) -> None:
|
| 1024 |
+
"""Initializes the `TzInfo`.
|
| 1025 |
+
|
| 1026 |
+
Arguments:
|
| 1027 |
+
seconds: The offset from UTC in seconds. Defaults to 0.0 (UTC).
|
| 1028 |
+
"""
|
| 1029 |
+
|
| 1030 |
+
def __new__(cls, seconds: float = 0.0) -> Self: ...
|
| 1031 |
+
|
| 1032 |
+
# Docstrings for attributes sourced from the abstract base class, [`datetime.tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo).
|
| 1033 |
+
|
| 1034 |
+
def tzname(self, dt: datetime.datetime | None) -> str | None:
|
| 1035 |
+
"""Return the time zone name corresponding to the [`datetime`][datetime.datetime] object _dt_, as a string.
|
| 1036 |
+
|
| 1037 |
+
For more info, see [`tzinfo.tzname`][datetime.tzinfo.tzname].
|
| 1038 |
+
"""
|
| 1039 |
+
|
| 1040 |
+
def utcoffset(self, dt: datetime.datetime | None) -> datetime.timedelta | None:
|
| 1041 |
+
"""Return offset of local time from UTC, as a [`timedelta`][datetime.timedelta] object that is positive east of UTC. If local time is west of UTC, this should be negative.
|
| 1042 |
+
|
| 1043 |
+
More info can be found at [`tzinfo.utcoffset`][datetime.tzinfo.utcoffset].
|
| 1044 |
+
"""
|
| 1045 |
+
|
| 1046 |
+
def dst(self, dt: datetime.datetime | None) -> datetime.timedelta | None:
|
| 1047 |
+
"""Return the daylight saving time (DST) adjustment, as a [`timedelta`][datetime.timedelta] object or `None` if DST information isn’t known.
|
| 1048 |
+
|
| 1049 |
+
More info can be found at[`tzinfo.dst`][datetime.tzinfo.dst]."""
|
| 1050 |
+
|
| 1051 |
+
def fromutc(self, dt: datetime.datetime) -> datetime.datetime:
|
| 1052 |
+
"""Adjust the date and time data associated datetime object _dt_, returning an equivalent datetime in self’s local time.
|
| 1053 |
+
|
| 1054 |
+
More info can be found at [`tzinfo.fromutc`][datetime.tzinfo.fromutc]."""
|
| 1055 |
+
|
| 1056 |
+
def __deepcopy__(self, _memo: dict[Any, Any]) -> TzInfo: ...
|
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/core_schema.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/pydantic_core/py.typed
ADDED
|
File without changes
|