weave.trace.weave_client
Functions
TypedDict(typename, fields=None, /, *, total=True, **kwargs)
A simple typed namespace. At runtime it is equivalent to a plain dict.
TypedDict creates a dictionary type that expects all of its
instances to have a certain set of keys, where each key is
associated with a value of a consistent type. This expectation
is not checked at runtime but is only enforced by type checkers.
Usage::
class Point2D(TypedDict):
x: int
y: int
label: str
a: Point2D = {‘x’: 1, ‘y’: 2, ‘label’: ‘good’} # OK
b: Point2D = {‘z’: 3, ‘label’: ‘bad’} # Fails type check
assert Point2D(x=1, y=2, label=‘first’) == dict(x=1, y=2, label=‘first’)
The type info can be accessed via the Point2D.annotations dict, and
the Point2D.required_keys and Point2D.optional_keys frozensets.
TypedDict supports two additional equivalent forms::
Point2D = TypedDict(‘Point2D’, x=int, y=int, label=str)
Point2D = TypedDict(‘Point2D’, {‘x’: int, ‘y’: int, ‘label’: str})
By default, all keys must be present in a TypedDict. It is possible
to override this by specifying totality.
Usage::
class point2D(TypedDict, total=False):
x: int
y: int
This means that a point2D TypedDict can have any of the keys omitted.A type
checker is only expected to support a literal False or True as the value of
the total argument. True is the default, and makes all items defined in the
class body be required.
The class syntax is only supported in Python 3.6+, while two other
syntax forms work for Python 2.7 and 3.2+
as_op(fn: 'Callable[P, R]') -> 'Op[P, R]'
Given a @weave.op() decorated function, return its Op.
@weave.op() decorated functions are instances of Op already, so this
function should be a no-op at runtime. But you can use it to satisfy type checkers
if you need to access OpDef attributes in a typesafe way.
Args:
fn: A weave.op() decorated function.
Returns:
The Op of the function.
cast(typ, val)
Cast a value to a type.
This returns the value unchanged. To the type checker this
signals that the return value has the designated type, but at
runtime we intentionally don’t check anything (we want this
to be as fast as possible).
check_endpoint_exists(func: Callable, test_req: Any, cache_key: Optional[str] = None) -> bool
Check if a function/endpoint exists and works by calling it with a test request.
This allows bypassing retry logic by passing the unwrapped function directly,
or testing any callable with consistent caching and error handling.
Args:
func: The function to test (e.g., server.table_create_from_digests or
server._generic_request_executor.wrapped)
test_req: A test request to use for checking the function
cache_key: Optional cache key. If not provided, uses id(func)
Returns:
True if function exists and works, False otherwise
check_wandb_run_matches(wandb_run_id: 'str | None', weave_entity: 'str', weave_project: 'str') -> 'None'
No description available.
client_parallelism() -> Optional[int]
No description available.
dataclass_object_record(obj: 'Any') -> 'ObjectRecord'
No description available.
deprecated(new_name: 'str') -> 'Callable[[Callable[..., Any]], Callable[..., Any]]'
Decorator to mark a function as deprecated and redirect users to new_name.
elide_display_name(name: 'str') -> 'str'
No description available.
exception_to_json_str(exception: 'BaseException') -> 'str'
No description available.
exists_expr(expr: Union[weave.trace_server.interface.query.LiteralOperation, weave.trace_server.interface.query.GetFieldOperator, weave.trace_server.interface.query.ConvertOperation, weave.trace_server.interface.query.AndOperation, weave.trace_server.interface.query.OrOperation, weave.trace_server.interface.query.NotOperation, weave.trace_server.interface.query.EqOperation, weave.trace_server.interface.query.GtOperation, weave.trace_server.interface.query.GteOperation, weave.trace_server.interface.query.InOperation, weave.trace_server.interface.query.ContainsOperation]) -> weave.trace_server.interface.query.NotOperation
No description available.
from_json(obj: 'Any', project_id: 'str', server: 'TraceServerInterface') -> 'Any'
No description available.
generate_id() -> str
Should be used to generate IDs for trace calls.
We use UUIDv7, which has a timestamp prefix, so that the IDs, while random,
are sortable by time. See RFC9562 https://www.rfc-editor.org/rfc/rfc9562.
Random space is 2^74, which is less than 2^122 (UUIDv4), but still plenty
for our use case.
get_field_expr(field: str) -> weave.trace_server.interface.query.GetFieldOperator
No description available.
get_obj_name(val: 'Any') -> 'str'
No description available.
get_parallelism_settings() -> 'tuple[int | None, int | None]'
No description available.
get_ref(obj: 'Any') -> 'ObjectRef | None'
No description available.
get_serializer_for_obj(obj: 'Any') -> 'Serializer | None'
No description available.
is_op(obj: 'Any') -> 'TypeIs[Op]'
Check if an object is an Op.
is_placeholder_call(call: 'Call') -> 'TypeIs[NoOpCall]'
No description available.
is_tracing_setting_disabled() -> 'bool'
No description available.
isinstance_namedtuple(obj: 'Any') -> 'bool'
No description available.
literal_expr(value: Any) -> weave.trace_server.interface.query.LiteralOperation
No description available.
make_client_call(entity: 'str', project: 'str', server_call: 'CallSchema', server: 'TraceServerInterface') -> 'WeaveObject'
No description available.
make_trace_obj(val: Any, new_ref: Optional[weave.trace.refs.RefWithExtra], server: weave.trace_server.trace_server_interface.TraceServerInterface, root: Optional[weave.trace.vals.Traceable], parent: Any = None) -> Any
No description available.
map_to_refs(obj: 'Any') -> 'Any'
No description available.
maybe_objectify(obj: 'WeaveObject') -> 'T_co | WeaveObject'
No description available.
maybe_unbind_method(oplike: 'Op | MethodType | partial') -> 'Op'
Unbind an Op-like method or partial to a plain Op function.
For:
- methods, remove set
selfparam - partials, remove any preset params
op(func: 'Callable[P, R] | None' = None, *, name: 'str | None' = None, call_display_name: 'str | CallDisplayNameFunc | None' = None, postprocess_inputs: 'PostprocessInputsFunc | None' = None, postprocess_output: 'PostprocessOutputFunc | None' = None, tracing_sample_rate: 'float' = 1.0, enable_code_capture: 'bool' = True, accumulator: 'Callable[[Any | None, Any], Any] | None' = None) -> 'Callable[[Callable[P, R]], Op[P, R]] | Op[P, R]'
A decorator to weave op-ify a function or method. Works for both sync and async.
Automatically detects iterator functions and applies appropriate behavior.
placeholder_call() -> 'Call'
No description available.
print_call_link(call: 'Call') -> 'None'
No description available.
pydantic_object_record(obj: 'BaseModel') -> 'ObjectRecord'
No description available.
redact_sensitive_keys(obj: 'Any') -> 'Any'
No description available.
remove_ref(obj: 'Any') -> 'None'
No description available.
runnable_feedback_output_selector(name: str) -> str
No description available.
runnable_feedback_runnable_ref_selector(name: str) -> str
No description available.
safe_current_wb_run_id() -> 'str | None'
No description available.
safe_current_wb_run_step() -> 'int | None'
No description available.
sanitize_object_name(name: 'str') -> 'str'
No description available.
set_ref(obj: 'Any', ref: 'Ref | None') -> 'None'
Try to set the ref on “any” object.
We use increasingly complex methods to try to set the ref
to support different kinds of objects. This will still
fail for python primitives, but those can’t be traced anyway.
should_capture_client_info() -> bool
No description available.
should_capture_system_info() -> bool
No description available.
should_print_call_link() -> bool
No description available.
should_redact(key: str) -> bool
Return whether a given key should be redacted.
Args:
key: The key name to check.
Returns:
True if the key is configured to be redacted (case-insensitive), False otherwise.
Examples:
from weave.utils import sanitize sanitize.should_redact(“API_KEY”) True sanitize.should_redact(“random_key”) False
should_redact_pii() -> bool
No description available.
should_skip_tracing_for_op(op: 'Op') -> 'bool'
No description available.
should_use_parallel_table_upload() -> bool
Returns whether parallel table upload chunking should be used.
sum_dict_leaves(dicts: list) -> dict
Recursively combines multiple dictionaries by summing their leaf values.
This function takes a list of dictionaries and combines them by:
- For non-dict values: extending lists or summing numbers
- For nested dictionaries: recursively combining them
Combining status counts from multiple runs
dicts = [ … {“status_counts”: {“SUCCESS”: 5, “FAILED”: 1}}, … {“status_counts”: {“SUCCESS”: 3, “FAILED”: 2, “PENDING”: 1}} … ] sum_dict_leaves(dicts) {‘status_counts’: {‘SUCCESS’: 8, ‘FAILED’: 3, ‘PENDING’: 1}}
Combining metrics with nested structure
dicts = [ … {“metrics”: {“accuracy”: 0.95, “loss”: 0.1, “details”: {“precision”: 0.9, “recall”: 0.8}}}, … {“metrics”: {“accuracy”: 0.97, “loss”: 0.08, “details”: {“precision”: 0.92, “f1”: 0.85}}} … ] sum_dict_leaves(dicts) {‘metrics’: {‘accuracy’: 1.92, ‘loss’: 0.18, ‘details’: {‘precision’: 1.82, ‘recall’: 0.8, ‘f1’: 0.85}}}
to_json(obj: 'Any', project_id: 'str', client: 'WeaveClient', use_dictify: 'bool' = False) -> 'Any'
No description available.
zip_dicts(base_dict: dict, new_dict: dict) -> dict
No description available.
Classes
AttributesDict
A dict representing the attributes of a call. Theweave key is reserved for internal use and cannot be set directly.
Attributes become immutable once the call is created. Any attempt to modify
the dictionary after call start will raise :class:TypeError. Use the
:func:weave.attributes context manager or the attributes parameter of
:meth:WeaveClient.create_call to supply metadata before the call begins.
Methods
__init__(self, **kwargs: Any) -> None
Initialize self. See help(type(self)) for accurate signature.
freeze(self) -> None
No description available.
unwrap(self) -> dict
No description available.
update(self, *args: Any, **kwargs: Any) -> None
D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
In either case, this is followed by: for k in F: D[k] = F[k]
Call
A Call represents a single operation executed as part of a trace.attributes are frozen once the call is created. Use
:func:weave.attributes or create_call(..., attributes=...) to
populate metadata beforehand. The summary dictionary may be
modified while the call is running; its contents are deep-merged
with computed summary values when :meth:WeaveClient.finish_call
is invoked.
Methods
__init__(self, _op_name: 'str | Future[str]', trace_id: 'str', project_id: 'str', parent_id: 'str | None', inputs: 'dict[str, Any]', id: 'str | None' = None, output: 'Any' = None, exception: 'str | None' = None, summary: 'dict[str, Any] | None' = <factory>, _display_name: 'str | Callable[[Call], str] | None' = None, attributes: 'dict[str, Any] | None' = None, started_at: 'datetime.datetime | None' = None, ended_at: 'datetime.datetime | None' = None, deleted_at: 'datetime.datetime | None' = None, thread_id: 'str | None' = None, turn_id: 'str | None' = None, wb_run_id: 'str | None' = None, wb_run_step: 'int | None' = None, wb_run_step_end: 'int | None' = None, _children: 'list[Call]' = <factory>, _feedback: 'RefFeedbackQuery | None' = None) -> None
No description available.
apply_scorer(self, scorer: 'Op | Scorer', additional_scorer_kwargs: 'dict[str, Any] | None' = None) -> 'ApplyScorerResult'
apply_scorer is a method that applies a Scorer to a Call. This is useful
for guarding application logic with a scorer and/or monitoring the quality
of critical ops. Scorers are automatically logged to Weave as Feedback and
can be used in queries & analysis.
Args:
scorer: The Scorer to apply.
additional_scorer_kwargs: Additional kwargs to pass to the scorer. This is
useful for passing in additional context that is not part of the call
inputs.useful for passing in additional context that is not part of the call
inputs.
Returns:
The result of the scorer application in the form of an ApplyScorerResult.
children(self, *, page_size: 'int' = 1000) -> 'CallsIter'
Get the children of the call.
Args:
page_size: Tune performance by changing the number of calls fetched at a time.
Returns:
An iterator of calls.
delete(self) -> 'bool'
Delete the call.
remove_display_name(self) -> 'None'
No description available.
set_display_name(self, name: 'str | None') -> 'None'
Set the display name for the call.
Args:
name: The display name to set for the call.
Example:
to_dict(self) -> 'CallDict'
No description available.
CallEndReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CallRef
CallRef(entity: ‘str’, project: ‘str’, id: ‘str’, _extra: ‘tuple[str | Future[str], …]’ = ())Methods
__init__(self, entity: 'str', project: 'str', id: 'str', _extra: 'tuple[str | Future[str], ...]' = ()) -> None
No description available.
as_param_dict(self) -> 'dict'
No description available.
maybe_parse_uri(s: 'str') -> 'AnyRef | None'
No description available.
parse_uri(uri: 'str') -> 'CallRef'
No description available.
uri(self) -> 'str'
No description available.
with_attr(self, attr: 'str') -> 'Self'
No description available.
with_extra(self, extra: 'tuple[str | Future[str], ...]') -> 'Self'
No description available.
with_index(self, index: 'int') -> 'Self'
No description available.
with_item(self, item_digest: 'str | Future[str]') -> 'Self'
No description available.
with_key(self, key: 'str') -> 'Self'
No description available.
CallStartReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CallUpdateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CallsDeleteReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CallsFilter
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CallsQueryReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
Chat
No description available.Methods
__init__(self, client: 'WeaveClient')
This class exists to mirror openai.resources.chat.chat.Chat
so we can have a drop-in compatible client.chat.completions.create call.
ChunkingConfig
Configuration for table chunking behavior.Methods
__init__(self, use_chunking: bool, use_parallel_chunks: bool) -> None
No description available.
CostCreateInput
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CostCreateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CostCreateRes
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CostPurgeReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CostQueryOutput
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
CostQueryReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
EndedCallSchemaForInsert
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
serialize_typed_dicts(self, v: dict) -> dict
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
FeedbackCreateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
FeedbackQuery
Lazy-loading object for fetching feedback from the server.Methods
__init__(self, entity: 'str', project: 'str', query: 'Query', offset: 'int | None' = None, limit: 'int | None' = None, show_refs: 'bool' = False)
Initialize self. See help(type(self)) for accurate signature.
execute(self) -> 'Feedbacks'
No description available.
refresh(self) -> 'Feedbacks'
No description available.
refs(self) -> 'Refs'
No description available.
FileCreateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
FileCreateRes
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
FlushStatus
Status information about the current flush operation.Future
Represents the result of an asynchronous computation.Methods
__init__(self)
Initializes the future. Should not be called by clients.
add_done_callback(self, fn)
Attaches a callable that will be called when the future finishes.
Args:
fn: A callable that will be called with this future as its only
argument when the future completes or is cancelled. The callable
will always be called by a thread in the same process in which
it was added. If the future has already completed or been
cancelled then the callable will be called immediately. These
callables are called in the order that they were added.
cancel(self)
Cancel the future if possible.
Returns True if the future was cancelled, False otherwise. A future
cannot be cancelled if it is running or has already completed.
cancelled(self)
Return True if the future was cancelled.
done(self)
Return True of the future was cancelled or finished executing.
exception(self, timeout=None)
Return the exception raised by the call that the future represents.
Args:
timeout: The number of seconds to wait for the exception if the
future isn’t done. If None, then there is no limit on the wait
time.
Returns:
The exception raised by the call that the future represents or None
if the call completed without raising.
Raises:
CancelledError: If the future was cancelled.
TimeoutError: If the future didn’t finish executing before the given
timeout.
result(self, timeout=None)
Return the result of the call that the future represents.
Args:
timeout: The number of seconds to wait for the result if the future
isn’t done. If None, then there is no limit on the wait time.
Returns:
The result of the call that the future represents.
Raises:
CancelledError: If the future was cancelled.
TimeoutError: If the future didn’t finish executing before the given
timeout.
Exception: If the call raised then that exception will be raised.
running(self)
Return True if the future is currently executing.
set_exception(self, exception)
Sets the result of the future as being the given exception.
Should only be used by Executor implementations and unit tests.
set_result(self, result)
Sets the return value of work associated with the future.
Should only be used by Executor implementations and unit tests.
set_running_or_notify_cancel(self)
Mark the future as running or process any cancel notifications.
Should only be used by Executor implementations and unit tests.
If the future has been cancelled (cancel() was called and returned
True) then any threads waiting on the future completing (though calls
to as_completed() or wait()) are notified and False is returned.
If the future was not cancelled then it is put in the running state
(future calls to running() will return True) and True is returned.
This method should be called by Executor implementations before
executing the work associated with this future. If this method returns
False then the work should not be executed.
Returns:
False if the Future was cancelled, True otherwise.
Raises:
RuntimeError: if this method was already called or if set_result()
or set_exception() was called.
FutureExecutor
A utility for thread-local threadpool execution and promise-like chaining. This class provides a thread-safe way to submit and execute jobs asynchronously using thread-local ThreadPoolExecutors. It ensures proper shutdown of the executors when the object is deleted or when the program exits. Args: max_workers (Optional[int]): The maximum number of worker threads to use per executor. Defaults to None. If set to 0, all tasks will be executed directly in the current thread. thread_name_prefix (str): The prefix for thread names. Defaults to “WeaveThreadPool”.Methods
__init__(self, max_workers: 'int | None' = None, thread_name_prefix: 'str' = 'WeaveThreadPool')
Initialize self. See help(type(self)) for accurate signature.
defer(self, f: 'Callable[..., T]', *args: 'Any', **kwargs: 'Any') -> 'Future[T]'
Defer a function to be executed in a thread pool.
This is useful for long-running or I/O-bound functions where the result is not needed immediately.
Args:
f (Callable[…, T]): The function to be executed.
*args: Positional arguments to pass to the function.
**kwargs: Keyword arguments to pass to the function.
Returns:
Future[T]: A Future object representing the eventual result of the function.
flush(self, timeout: 'float | None' = None) -> 'bool'
Block until all currently submitted items are complete or timeout is reached.
This method allows new submissions while waiting, ensuring that
submitted jobs can enqueue more items if needed to complete.
Args:
timeout (Optional[float]): Maximum time to wait in seconds. If None, wait indefinitely.
Returns:
bool: True if all tasks completed
Raises:
RuntimeError: If called from within a thread context.
TimeoutError: If the timeout is reached.
then(self, futures: 'list[Future[T]]', g: 'Callable[[list[T]], U]') -> 'Future[U]'
Execute a function on the results of a list of futures.
This is useful when the results of one or more futures are needed for further processing.
Args:
futures (list[Future[T]]): A list of Future objects.
g (Callable[[list[T]], U]): A function that takes the results of the futures and returns a value of type U.
Returns:
Future[U]: A new Future object representing the result of applying g to the results of the futures.
HTTPError
An HTTP error occurred.Methods
__init__(self, *args, **kwargs)
Initialize RequestException with request and response objects.
InferenceModels
No description available.Methods
__init__(self, client: 'WeaveClient')
This class exists to mirror openai.resources.models.Models.
It is not a drop-in replacement because of the terminology conflict
with Weave’s “Model”.
list(self) -> Union[weave.chat.types.models.ModelsResponseSuccess, weave.chat.types.models.ModelsResponseError]
No description available.
ObjCreateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjCreateRes
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjDeleteReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjQueryReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjReadReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjSchema
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjSchemaForInsert
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, _ObjSchemaForInsert__context: Any) -> None
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
ObjectRecord
No description available.Methods
__init__(self, attrs: 'dict[str, Any]') -> 'None'
Initialize self. See help(type(self)) for accurate signature.
map_values(self, fn: 'Callable') -> 'ObjectRecord'
No description available.
unwrap(self) -> 'dict[str, Any]'
No description available.
ObjectRef
ObjectRef(entity: ‘str’, project: ‘str’, name: ‘str’, _digest: ‘str | Future[str]’, _extra: ‘tuple[str | Future[str], …]’ = ())Methods
__init__(self, entity: 'str', project: 'str', name: 'str', _digest: 'str | Future[str]', _extra: 'tuple[str | Future[str], ...]' = ()) -> None
No description available.
as_param_dict(self) -> 'dict'
No description available.
delete(self) -> 'None'
No description available.
get(self, *, objectify: 'bool' = True) -> 'Any'
No description available.
is_descended_from(self, potential_ancestor: 'ObjectRef') -> 'bool'
No description available.
maybe_parse_uri(s: 'str') -> 'AnyRef | None'
No description available.
parse_uri(uri: 'str') -> 'ObjectRef'
No description available.
uri(self) -> 'str'
No description available.
with_attr(self, attr: 'str') -> 'Self'
No description available.
with_extra(self, extra: 'tuple[str | Future[str], ...]') -> 'Self'
No description available.
with_index(self, index: 'int') -> 'Self'
No description available.
with_item(self, item_digest: 'str | Future[str]') -> 'Self'
No description available.
with_key(self, key: 'str') -> 'Self'
No description available.
ObjectVersionFilter
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
Op
The interface for Op-ified functions and methods. Op was previously a class, and has been converted to a Protocol to allow functions to pass for Op. This is needed because many popular packages are using theinspect module for control flow, and Op instances don’t always
pass those checks. In particular, inspect.iscoroutinefunction always
fails for classes, even ones that implement async methods or protocols.
Some of the attributes are carry-overs from when Op was a class. We should
consider removing the unnecessary ones where possible.
- resolve_fn (I think you can just use the func itself?)
- _set_on_output_handler (does this have to be on the op?)
- _on_output_handler (does this have to be on the op?)
Methods
_no_init(self, *args, **kwargs)
No description available.
OpRef
OpRef(entity: ‘str’, project: ‘str’, name: ‘str’, _digest: ‘str | Future[str]’, _extra: ‘tuple[str | Future[str], …]’ = ())Methods
__init__(self, entity: 'str', project: 'str', name: 'str', _digest: 'str | Future[str]', _extra: 'tuple[str | Future[str], ...]' = ()) -> None
No description available.
as_param_dict(self) -> 'dict'
No description available.
delete(self) -> 'None'
No description available.
get(self, *, objectify: 'bool' = True) -> 'Any'
No description available.
is_descended_from(self, potential_ancestor: 'ObjectRef') -> 'bool'
No description available.
maybe_parse_uri(s: 'str') -> 'AnyRef | None'
No description available.
parse_uri(uri: 'str') -> 'OpRef'
No description available.
uri(self) -> 'str'
No description available.
with_attr(self, attr: 'str') -> 'Self'
No description available.
with_extra(self, extra: 'tuple[str | Future[str], ...]') -> 'Self'
No description available.
with_index(self, index: 'int') -> 'Self'
No description available.
with_item(self, item_digest: 'str | Future[str]') -> 'Self'
No description available.
with_key(self, key: 'str') -> 'Self'
No description available.
PendingJobCounts
Counts of pending jobs for each type.Query
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
Ref
Ref()Methods
__init__(self) -> None
No description available.
as_param_dict(self) -> 'dict'
No description available.
maybe_parse_uri(s: 'str') -> 'AnyRef | None'
No description available.
parse_uri(uri: 'str') -> 'AnyRef'
No description available.
uri(self) -> 'str'
No description available.
RefsReadBatchReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
Sequence
All the operations on a read-only sequence. Concrete subclasses must override new or init, getitem, and len.Methods
count(self, value)
S.count(value) -> integer — return number of occurrences of value
index(self, value, start=0, stop=None)
S.index(value, [start, [stop]]) -> integer — return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but
recommended.
StartedCallSchemaForInsert
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
Table
No description available.Methods
__init__(self, rows: 'list[dict]') -> 'None'
Initialize self. See help(type(self)) for accurate signature.
append(self, row: 'dict') -> 'None'
Add a row to the table.
pop(self, index: 'int') -> 'None'
Remove a row at the given index from the table.
TableAppendSpec
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TableAppendSpecPayload
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TableChunkManager
Manages concurrent creation of table chunks with proper error handling.Methods
__init__(self, target_chunk_bytes: int = 10485760)
Initialize self. See help(type(self)) for accurate signature.
calculate_request_bytes(self, req: Any) -> int
Calculate the estimated size in bytes of a request.
calculate_row_bytes(self, row: object) -> int
Calculate the size in bytes of a single row.
create_chunks(self, rows: collections.abc.Sequence) -> list
Split rows into chunks based on target byte size.
Args:
rows: List of rows to chunk
Returns:
List of row chunks
TableCreateFromDigestsReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TableCreateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TableCreateRes
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TableRef
TableRef(entity: ‘str’, project: ‘str’, _digest: ‘str | Future[str]’, _row_digests: ‘list[str] | Future[list[str]] | None’ = None)Methods
__init__(self, entity: 'str', project: 'str', _digest: 'str | Future[str]', _row_digests: 'list[str] | Future[list[str]] | None' = None) -> None
No description available.
as_param_dict(self) -> 'dict'
No description available.
maybe_parse_uri(s: 'str') -> 'AnyRef | None'
No description available.
parse_uri(uri: 'str') -> 'TableRef'
No description available.
uri(self) -> 'str'
No description available.
TableSchemaForInsert
!!! abstract “Usage Documentation” Models A base class for creating Pydantic models. Attributes: class_vars: The names of the class variables defined on the model. private_attributes: Metadata about the private attributes of the model. signature: The synthesized__init__ [Signature][inspect.Signature] of the model.
pydantic_complete: Whether model building is completed, or if there are still undefined fields.
pydantic_core_schema: The core schema of the model.
pydantic_custom_init: Whether the model has a custom __init__ function.
pydantic_decorators: Metadata containing the decorators defined on the model.
This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
pydantic_generic_metadata: Metadata for generic models; contains data used for a similar purpose to
args, origin, parameters in typing-module generics. May eventually be replaced by these.
pydantic_parent_namespace: Parent namespace of the model, used for automatic rebuilding of models.
pydantic_post_init: The name of the post-init method for the model, if defined.
pydantic_root_model: Whether the model is a [RootModel][pydantic.root_model.RootModel].
pydantic_serializer: The pydantic-core SchemaSerializer used to dump instances of the model.
pydantic_validator: The pydantic-core SchemaValidator used to validate instances of the model.
pydantic_fields: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
pydantic_computed_fields: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
pydantic_extra: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra]
is set to 'allow'.
pydantic_fields_set: The names of fields explicitly set during instantiation.
pydantic_private: Values of private attributes set on the model instance.
Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TableUpdateReq
Base model with strict validation that forbids extra fields.Methods
__init__(self, /, **data: 'Any') -> 'None'
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
No description available.
copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' = None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update: 'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
Returns a copy of the model.
!!! warning “Deprecated”
This method is now deprecated; use model_copy instead.
If you need include or exclude, use:
dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
No description available.
from_orm(obj: 'Any') -> 'Self'
No description available.
json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] | None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined, **dumps_kwargs: 'Any') -> 'str'
No description available.
model_construct(_fields_set: 'set[str] | None' = None, **values: 'Any') -> 'Self'
Creates a new instance of the Model class with validated data.
Creates a new model setting __dict__ and __pydantic_fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
!!! note
model_construct() generally respects the model_config.extra setting on the provided model.
That is, if model_config.extra == 'allow', then all extra passed values are added to the model instance’s __dict__
and __pydantic_extra__ fields. If model_config.extra == 'ignore' (the default), then all extra passed values are ignored.
Because no validation is performed with a call to model_construct(), having model_config.extra == 'forbid' does not result in
an error if extra values are passed, but they will be ignored.
Args:
_fields_set: A set of field names that were originally explicitly set during instantiation. If provided,
this is directly used for the [model_fields_set][pydantic.BaseModel.model_fields_set] attribute.
Otherwise, the field names from the values argument will be used.
values: Trusted or pre-validated data dictionary.
Returns:
A new instance of the Model class with validated data.
model_copy(self, *, update: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
!!! abstract “Usage Documentation”
model_copy
Returns a copy of the model.
!!! note
The underlying instance’s [__dict__][object.dict] attribute is copied. This
might have unexpected side effects if you store anything in it, on top of the model
fields (e.g. the value of [cached properties][functools.cached_property]).
Args:
update: Values to change/add in the new model. Note: the data is not validated
before creating the new model. You should trust this data.
deep: Set to True to make a deep copy of the model.
Returns:
New model instance.
model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python', include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
!!! abstract “Usage Documentation”
model_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Args:
mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types.
If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output.
exclude: A set of fields to exclude from the output.
context: Additional context to pass to the serializer.
by_alias: Whether to use the field’s alias in the dictionary key if defined.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A dictionary representation of the model.
model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, exclude_unset: 'bool' = False, exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool | Literal['none', 'warn', 'error']" = True, fallback: 'Callable[[Any], Any] | None' = None, serialize_as_any: 'bool' = False) -> 'str'
!!! abstract “Usage Documentation”
model_dump_json
Generates a JSON representation of the model using Pydantic’s to_json method.
Args:
indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
include: Field(s) to include in the JSON output.
exclude: Field(s) to exclude from the JSON output.
context: Additional context to pass to the serializer.
by_alias: Whether to serialize using field aliases.
exclude_unset: Whether to exclude fields that have not been explicitly set.
exclude_defaults: Whether to exclude fields that are set to their default value.
exclude_none: Whether to exclude fields that have a value of None.
round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].
warnings: How to handle serialization errors. False/“none” ignores them, True/“warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
fallback: A function to call when an unknown value is encountered. If not provided,
a [PydanticSerializationError][pydantic_core.PydanticSerializationError] error is raised.
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
Returns:
A JSON string representation of the model.
model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class 'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]'
Generates a JSON schema for a model class.
Args:
by_alias: Whether to use attribute aliases or not.
ref_template: The reference template.
schema_generator: To override the logic used to generate the JSON schema, as a subclass of
GenerateJsonSchema with your desired modifications
mode: The mode in which to generate the schema.
Returns:
The JSON schema for the given model class.
model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
Args:
params: Tuple of types of the class. Given a generic class
Model with 2 type variables and a concrete model Model[str, int],
the value (str, int) would be passed to params.
Returns:
String representing the new class where params are passed to cls as type variables.
Raises:
TypeError: Raised when trying to generate concrete names for non-generic models.
model_post_init(self, context: 'Any', /) -> 'None'
Override this method to perform additional initialization after __init__ and model_construct.
This is useful if you want to do some validation that requires the entire model to be initialized.
model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True, _parent_namespace_depth: 'int' = 2, _types_namespace: 'MappingNamespace | None' = None) -> 'bool | None'
Try to rebuild the pydantic-core schema for the model.
This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
the initial attempt to build the schema, and automatic rebuilding fails.
Args:
force: Whether to force the rebuilding of the model schema, defaults to False.
raise_errors: Whether to raise errors, defaults to True.
_parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
_types_namespace: The types namespace, defaults to None.
Returns:
Returns None if the schema is already “complete” and rebuilding was not required.
If rebuilding was required, returns True if rebuilding was successful, otherwise False.
model_validate(obj: 'Any', *, strict: 'bool | None' = None, from_attributes: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate a pydantic model instance.
Args:
obj: The object to validate.
strict: Whether to enforce types strictly.
from_attributes: Whether to extract data from object attributes.
context: Additional context to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Raises:
ValidationError: If the object could not be validated.
Returns:
The validated model instance.
model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
!!! abstract “Usage Documentation”
JSON Parsing
Validate the given JSON data against the Pydantic model.
Args:
json_data: The JSON data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
Raises:
ValidationError: If json_data is not a JSON string or the object could not be validated.
model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None, context: 'Any | None' = None, by_alias: 'bool | None' = None, by_name: 'bool | None' = None) -> 'Self'
Validate the given object with string data against the Pydantic model.
Args:
obj: The object containing string data to validate.
strict: Whether to enforce types strictly.
context: Extra variables to pass to the validator.
by_alias: Whether to use the field’s alias when validating against the provided input data.
by_name: Whether to use the field’s name when validating against the provided input data.
Returns:
The validated Pydantic model.
parse_file(path: 'str | Path', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
parse_obj(obj: 'Any') -> 'Self'
No description available.
parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self'
No description available.
schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]'
No description available.
schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
No description available.
update_forward_refs(**localns: 'Any') -> 'None'
No description available.
validate(value: 'Any') -> 'Self'
No description available.
TraceServerInterface
Base class for protocol classes. Protocol classes are defined as:: class Proto(Protocol): def meth(self) -> int: … Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example:: class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:: class GenProto(Protocol[T]): def meth(self) -> T: …Methods
_no_init(self, *args, **kwargs)
No description available.
actions_execute_batch(self, req: weave.trace_server.trace_server_interface.ActionsExecuteBatchReq) -> weave.trace_server.trace_server_interface.ActionsExecuteBatchRes
No description available.
call_end(self, req: weave.trace_server.trace_server_interface.CallEndReq) -> weave.trace_server.trace_server_interface.CallEndRes
No description available.
call_read(self, req: weave.trace_server.trace_server_interface.CallReadReq) -> weave.trace_server.trace_server_interface.CallReadRes
No description available.
call_start(self, req: weave.trace_server.trace_server_interface.CallStartReq) -> weave.trace_server.trace_server_interface.CallStartRes
No description available.
call_start_batch(self, req: weave.trace_server.trace_server_interface.CallCreateBatchReq) -> weave.trace_server.trace_server_interface.CallCreateBatchRes
No description available.
call_update(self, req: weave.trace_server.trace_server_interface.CallUpdateReq) -> weave.trace_server.trace_server_interface.CallUpdateRes
No description available.
calls_delete(self, req: weave.trace_server.trace_server_interface.CallsDeleteReq) -> weave.trace_server.trace_server_interface.CallsDeleteRes
No description available.
calls_query(self, req: weave.trace_server.trace_server_interface.CallsQueryReq) -> weave.trace_server.trace_server_interface.CallsQueryRes
No description available.
calls_query_stats(self, req: weave.trace_server.trace_server_interface.CallsQueryStatsReq) -> weave.trace_server.trace_server_interface.CallsQueryStatsRes
No description available.
calls_query_stream(self, req: weave.trace_server.trace_server_interface.CallsQueryReq) -> collections.abc.Iterator
No description available.
completions_create(self, req: weave.trace_server.trace_server_interface.CompletionsCreateReq) -> weave.trace_server.trace_server_interface.CompletionsCreateRes
No description available.
completions_create_stream(self, req: weave.trace_server.trace_server_interface.CompletionsCreateReq) -> collections.abc.Iterator
No description available.
cost_create(self, req: weave.trace_server.trace_server_interface.CostCreateReq) -> weave.trace_server.trace_server_interface.CostCreateRes
No description available.
cost_purge(self, req: weave.trace_server.trace_server_interface.CostPurgeReq) -> weave.trace_server.trace_server_interface.CostPurgeRes
No description available.
cost_query(self, req: weave.trace_server.trace_server_interface.CostQueryReq) -> weave.trace_server.trace_server_interface.CostQueryRes
No description available.
ensure_project_exists(self, entity: str, project: str) -> weave.trace_server.trace_server_interface.EnsureProjectExistsRes
No description available.
evaluate_model(self, req: weave.trace_server.trace_server_interface.EvaluateModelReq) -> weave.trace_server.trace_server_interface.EvaluateModelRes
No description available.
evaluation_status(self, req: weave.trace_server.trace_server_interface.EvaluationStatusReq) -> weave.trace_server.trace_server_interface.EvaluationStatusRes
No description available.
feedback_create(self, req: weave.trace_server.trace_server_interface.FeedbackCreateReq) -> weave.trace_server.trace_server_interface.FeedbackCreateRes
No description available.
feedback_create_batch(self, req: weave.trace_server.trace_server_interface.FeedbackCreateBatchReq) -> weave.trace_server.trace_server_interface.FeedbackCreateBatchRes
No description available.
feedback_purge(self, req: weave.trace_server.trace_server_interface.FeedbackPurgeReq) -> weave.trace_server.trace_server_interface.FeedbackPurgeRes
No description available.
feedback_query(self, req: weave.trace_server.trace_server_interface.FeedbackQueryReq) -> weave.trace_server.trace_server_interface.FeedbackQueryRes
No description available.
feedback_replace(self, req: weave.trace_server.trace_server_interface.FeedbackReplaceReq) -> weave.trace_server.trace_server_interface.FeedbackReplaceRes
No description available.
file_content_read(self, req: weave.trace_server.trace_server_interface.FileContentReadReq) -> weave.trace_server.trace_server_interface.FileContentReadRes
No description available.
file_create(self, req: weave.trace_server.trace_server_interface.FileCreateReq) -> weave.trace_server.trace_server_interface.FileCreateRes
No description available.
files_stats(self, req: weave.trace_server.trace_server_interface.FilesStatsReq) -> weave.trace_server.trace_server_interface.FilesStatsRes
No description available.
image_create(self, req: weave.trace_server.trace_server_interface.ImageGenerationCreateReq) -> weave.trace_server.trace_server_interface.ImageGenerationCreateRes
No description available.
obj_create(self, req: weave.trace_server.trace_server_interface.ObjCreateReq) -> weave.trace_server.trace_server_interface.ObjCreateRes
No description available.
obj_delete(self, req: weave.trace_server.trace_server_interface.ObjDeleteReq) -> weave.trace_server.trace_server_interface.ObjDeleteRes
No description available.
obj_read(self, req: weave.trace_server.trace_server_interface.ObjReadReq) -> weave.trace_server.trace_server_interface.ObjReadRes
No description available.
objs_query(self, req: weave.trace_server.trace_server_interface.ObjQueryReq) -> weave.trace_server.trace_server_interface.ObjQueryRes
No description available.
op_create(self, req: weave.trace_server.trace_server_interface.OpCreateReq) -> weave.trace_server.trace_server_interface.OpCreateRes
No description available.
op_read(self, req: weave.trace_server.trace_server_interface.OpReadReq) -> weave.trace_server.trace_server_interface.OpReadRes
No description available.
ops_query(self, req: weave.trace_server.trace_server_interface.OpQueryReq) -> weave.trace_server.trace_server_interface.OpQueryRes
No description available.
otel_export(self, req: weave.trace_server.trace_server_interface.OtelExportReq) -> weave.trace_server.trace_server_interface.OtelExportRes
No description available.
project_stats(self, req: weave.trace_server.trace_server_interface.ProjectStatsReq) -> weave.trace_server.trace_server_interface.ProjectStatsRes
No description available.
refs_read_batch(self, req: weave.trace_server.trace_server_interface.RefsReadBatchReq) -> weave.trace_server.trace_server_interface.RefsReadBatchRes
No description available.
table_create(self, req: weave.trace_server.trace_server_interface.TableCreateReq) -> weave.trace_server.trace_server_interface.TableCreateRes
No description available.
table_create_from_digests(self, req: weave.trace_server.trace_server_interface.TableCreateFromDigestsReq) -> weave.trace_server.trace_server_interface.TableCreateFromDigestsRes
No description available.
table_query(self, req: weave.trace_server.trace_server_interface.TableQueryReq) -> weave.trace_server.trace_server_interface.TableQueryRes
No description available.
table_query_stats(self, req: weave.trace_server.trace_server_interface.TableQueryStatsReq) -> weave.trace_server.trace_server_interface.TableQueryStatsRes
No description available.
table_query_stats_batch(self, req: weave.trace_server.trace_server_interface.TableQueryStatsBatchReq) -> weave.trace_server.trace_server_interface.TableQueryStatsBatchRes
No description available.
table_query_stream(self, req: weave.trace_server.trace_server_interface.TableQueryReq) -> collections.abc.Iterator
No description available.
table_update(self, req: weave.trace_server.trace_server_interface.TableUpdateReq) -> weave.trace_server.trace_server_interface.TableUpdateRes
No description available.
threads_query_stream(self, req: weave.trace_server.trace_server_interface.ThreadsQueryReq) -> collections.abc.Iterator
No description available.
TraceStatus
An enumeration.WeaveClient
No description available.Methods
__init__(self, entity: 'str', project: 'str', server: 'TraceServerInterface', ensure_project_exists: 'bool' = True)
Initialize self. See help(type(self)) for accurate signature.
add_cost(self, llm_id: 'str', prompt_token_cost: 'float', completion_token_cost: 'float', effective_date: 'datetime.datetime | None' = None, prompt_token_cost_unit: 'str | None' = 'USD', completion_token_cost_unit: 'str | None' = 'USD', provider_id: 'str | None' = 'default') -> 'CostCreateRes'
Add a cost to the current project.
Examples:
call(self, call_id: 'str', include_costs: 'bool' = False) -> 'WeaveObject'
No description available.
calls(self, filter: 'CallsFilter | None' = None, include_costs: 'bool' = False) -> 'CallsIter'
No description available.
create_call(self, op: 'str | Op', inputs: 'dict[str, Any]', parent: 'Call | None' = None, attributes: 'dict[str, Any] | None' = None, display_name: 'str | Callable[[Call], str] | None' = None, *, use_stack: 'bool' = True, _call_id_override: 'str | None' = None) -> 'Call'
Create, log, and push a call onto the runtime stack.
Args:
op: The operation producing the call, or the name of an anonymous operation.
inputs: The inputs to the operation.
parent: The parent call. If parent is not provided, the current run is used as the parent.
display_name: The display name for the call. Defaults to None.
attributes: The attributes for the call. Defaults to None.
use_stack: Whether to push the call onto the runtime stack. Defaults to True.
Returns:
The created Call object.
delete_all_object_versions(self, object_name: 'str') -> 'int'
Delete all versions of an object.
Args:
object_name: The name of the object whose versions should be deleted.
Returns:
The number of versions deleted.
delete_all_op_versions(self, op_name: 'str') -> 'int'
Delete all versions of an op.
Args:
op_name: The name of the op whose versions should be deleted.
Returns:
The number of versions deleted.
delete_call(self, call: 'Call') -> 'None'
No description available.
delete_calls(self, call_ids: 'list[str]') -> 'None'
Delete calls by their IDs.
Deleting a call will also delete all of its children.
Args:
call_ids: A list of call IDs to delete. Ex: [“2F0193e107-8fcf-7630-b576-977cc3062e2e”]
delete_object_version(self, object: 'ObjectRef') -> 'None'
No description available.
delete_object_versions(self, object_name: 'str', digests: 'list[str]') -> 'int'
Delete specific versions of an object.
Args:
object_name: The name of the object whose versions should be deleted.
digests: List of digests to delete. Can include aliases like “latest” or “v0”.
Returns:
The number of versions deleted.
delete_op_version(self, op: 'OpRef') -> 'None'
No description available.
fail_call(self, call: 'Call', exception: 'BaseException') -> 'None'
Fail a call with an exception. This is a convenience method for finish_call.
feedback(self, query: 'Query | str | None' = None, *, reaction: 'str | None' = None, offset: 'int' = 0, limit: 'int' = 100) -> 'FeedbackQuery'
No description available.
finish(self, use_progress_bar: 'bool' = True, callback: 'Callable[[FlushStatus], None] | None' = None) -> 'None'
Flushes all background tasks to ensure they are processed.
This method blocks until all currently enqueued jobs are processed,
displaying a progress bar to show the status of the pending tasks.
It ensures parallel processing during main thread execution and can
improve performance when user code completes before data has been
uploaded to the server.
Args:
use_progress_bar: Whether to display a progress bar during flush.
Set to False for environments where a progress bar
would not render well (e.g., CI environments).
callback: Optional callback function that receives status updates.
Overrides use_progress_bar.
finish_call(self, call: 'Call', output: 'Any' = None, exception: 'BaseException | None' = None, *, op: 'Op | None' = None) -> 'None'
Finalize a call and persist its results.
Any values present in call.summary are deep-merged with computed
summary statistics (e.g. usage and status counts) before being written
to the database.
flush(self) -> 'None'
Flushes background asynchronous tasks, safe to call multiple times.
get(self, ref: 'ObjectRef', *, objectify: 'bool' = True) -> 'Any'
No description available.
get_call(self, call_id: 'str', include_costs: 'bool' = False, include_feedback: 'bool' = False, columns: 'list[str] | None' = None) -> 'WeaveObject'
Get a single call by its ID.
Args:
call_id: The ID of the call to get.
include_costs: If true, cost info is included at summary.weave
include_feedback: If true, feedback info is included at summary.weave.feedback
columns: A list of columns to include in the response. If None,
all columns are included. Specifying fewer columns may be more performant.
Some columns are always included: id, project_id, trace_id, op_name, started_at
Returns:
A call object.
get_calls(self, *, filter: 'CallsFilterLike | None' = None, limit: 'int | None' = None, offset: 'int | None' = None, sort_by: 'list[SortByLike] | None' = None, query: 'QueryLike | None' = None, include_costs: 'bool' = False, include_feedback: 'bool' = False, columns: 'list[str] | None' = None, expand_columns: 'list[str] | None' = None, return_expanded_column_values: 'bool' = True, scored_by: 'str | list[str] | None' = None, page_size: 'int' = 1000) -> 'CallsIter'
Retrieve a list of traced calls (operations) for this project.
This method provides a powerful and flexible interface for querying trace data.
It supports pagination, filtering, sorting, field projection, and scoring metadata,
and can be used to power custom trace UIs or analysis tools.
Performance Tip: Specify columns and use filter or query to reduce result size.
Args:
filter: High-level filter for narrowing results by fields like op_name, parent_ids, etc.
limit: Maximum number of calls to return.
offset: Number of calls to skip before returning results (used for pagination).
sort_by: List of fields to sort the results by (e.g., started_at desc).
query: A mongo-like expression for advanced filtering. Not all Mongo operators are supported.
include_costs: If True, includes token/cost info in summary.weave.
include_feedback: If True, includes feedback in summary.weave.feedback.
columns: List of fields to return per call. Reducing this can significantly improve performance.
(Some fields like id, trace_id, op_name, and started_at are always included.)
scored_by: Filter by one or more scorers (name or ref URI). Multiple scorers are AND-ed.
page_size: Number of calls fetched per page. Tune this for performance in large queries.
Returns:
CallsIter: An iterator over Call objects. Supports slicing, iteration, and .to_pandas().
Example:
get_evaluation(self, uri: 'str') -> 'Evaluation'
Retrieve a specific Evaluation object by its URI.
Evaluation URIs typically follow the format:
weave:///entity/project/object/Evaluation:version
You can also get the evaluation by its “friendly” name:
get_evaluation(“Evaluation:v1”)
Args:
uri (str): The unique resource identifier of the evaluation to retrieve.
Returns:
Evaluation: The Evaluation object corresponding to the provided URI.
Raises:
TypeError: If the object at the URI is not an Evaluation instance.
ValueError: If the URI is invalid or the object cannot be found.
Examples: