kittycad.models.selection.OptionMeshByName
- class kittycad.models.selection.OptionMeshByName(**data)[source][source]
Bases:
BaseModel
Visit the first mesh with the given name.
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 allowself
as a field name.- __init__(**data)[source]
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 allowself
as a field name.
Methods
__init__
(**data)Create a new model by parsing and validating input data from keyword arguments.
construct
([_fields_set])copy
(*[, include, exclude, update, deep])Returns a copy of the model.
dict
(*[, include, exclude, by_alias, ...])from_orm
(obj)json
(*[, include, exclude, by_alias, ...])model_construct
([_fields_set])Creates a new instance of the
Model
class with validated data.model_copy
(*[, update, deep])Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
model_dump
(*[, mode, include, exclude, ...])Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
model_dump_json
(*[, indent, include, ...])Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
model_json_schema
([by_alias, ref_template, ...])Generates a JSON schema for a model class.
model_parametrized_name
(params)Compute the class name for parametrizations of generic classes.
model_post_init
(_BaseModel__context)Override this method to perform additional initialization after
__init__
andmodel_construct
.model_rebuild
(*[, force, raise_errors, ...])Try to rebuild the pydantic-core schema for the model.
model_validate
(obj, *[, strict, ...])Validate a pydantic model instance.
model_validate_json
(json_data, *[, strict, ...])Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
model_validate_strings
(obj, *[, strict, context])Validate the given object with string data against the Pydantic model.
parse_file
(path, *[, content_type, ...])parse_obj
(obj)parse_raw
(b, *[, content_type, encoding, ...])schema
([by_alias, ref_template])schema_json
(*[, by_alias, ref_template])update_forward_refs
(**localns)validate
(value)Attributes
A dictionary of computed field names and their corresponding
ComputedFieldInfo
objects.Configuration for the model, should be a dictionary conforming to [
ConfigDict
][pydantic.config.ConfigDict].Get extra fields set during validation.
Metadata about the fields defined on the model, mapping of field names to [
FieldInfo
][pydantic.fields.FieldInfo] objects.Returns the set of fields that have been explicitly set on this model instance.
- __annotations__ = {'__class_vars__': 'ClassVar[set[str]]', '__private_attributes__': 'ClassVar[Dict[str, ModelPrivateAttr]]', '__pydantic_complete__': 'ClassVar[bool]', '__pydantic_core_schema__': 'ClassVar[CoreSchema]', '__pydantic_custom_init__': 'ClassVar[bool]', '__pydantic_decorators__': 'ClassVar[_decorators.DecoratorInfos]', '__pydantic_extra__': 'dict[str, Any] | None', '__pydantic_fields_set__': 'set[str]', '__pydantic_generic_metadata__': 'ClassVar[_generics.PydanticGenericMetadata]', '__pydantic_parent_namespace__': 'ClassVar[Dict[str, Any] | None]', '__pydantic_post_init__': "ClassVar[None | Literal['model_post_init']]", '__pydantic_private__': 'dict[str, Any] | None', '__pydantic_root_model__': 'ClassVar[bool]', '__pydantic_serializer__': 'ClassVar[SchemaSerializer]', '__pydantic_validator__': 'ClassVar[SchemaValidator | PluggableSchemaValidator]', '__signature__': 'ClassVar[Signature]', 'model_computed_fields': 'ClassVar[Dict[str, ComputedFieldInfo]]', 'model_config': 'ClassVar[ConfigDict]', 'model_fields': 'ClassVar[Dict[str, FieldInfo]]', 'name': <class 'str'>, 'type': typing.Literal['mesh_by_name']}[source]
- classmethod __class_getitem__(typevar_values)[source]
- Return type:
type
[BaseModel
] |PydanticRecursiveRef
- __class_vars__: ClassVar[set[str]] = {}[source]
The names of the class variables defined on the model.
- classmethod __get_pydantic_core_schema__(source, handler, /)[source]
Hook into generating the model’s CoreSchema.
- Parameters:
source (
type
[BaseModel
]) – The class we are generating a schema for. This will generally be the same as thecls
argument if this is a classmethod.handler (
GetCoreSchemaHandler
) – A callable that calls into Pydantic’s internal CoreSchema generation logic.
- Return type:
Union
[AnySchema
,NoneSchema
,BoolSchema
,IntSchema
,FloatSchema
,DecimalSchema
,StringSchema
,BytesSchema
,DateSchema
,TimeSchema
,DatetimeSchema
,TimedeltaSchema
,LiteralSchema
,EnumSchema
,IsInstanceSchema
,IsSubclassSchema
,CallableSchema
,ListSchema
,TupleSchema
,SetSchema
,FrozenSetSchema
,GeneratorSchema
,DictSchema
,AfterValidatorFunctionSchema
,BeforeValidatorFunctionSchema
,WrapValidatorFunctionSchema
,PlainValidatorFunctionSchema
,WithDefaultSchema
,NullableSchema
,UnionSchema
,TaggedUnionSchema
,ChainSchema
,LaxOrStrictSchema
,JsonOrPythonSchema
,TypedDictSchema
,ModelFieldsSchema
,ModelSchema
,DataclassArgsSchema
,DataclassSchema
,ArgumentsSchema
,CallSchema
,CustomErrorSchema
,JsonSchema
,UrlSchema
,MultiHostUrlSchema
,DefinitionsSchema
,DefinitionReferenceSchema
,UuidSchema
,ComplexSchema
]- Returns:
A
pydantic-core
CoreSchema
.
- classmethod __get_pydantic_json_schema__(core_schema, handler, /)[source]
Hook into generating the model’s JSON schema.
- Parameters:
core_schema (
Union
[AnySchema
,NoneSchema
,BoolSchema
,IntSchema
,FloatSchema
,DecimalSchema
,StringSchema
,BytesSchema
,DateSchema
,TimeSchema
,DatetimeSchema
,TimedeltaSchema
,LiteralSchema
,EnumSchema
,IsInstanceSchema
,IsSubclassSchema
,CallableSchema
,ListSchema
,TupleSchema
,SetSchema
,FrozenSetSchema
,GeneratorSchema
,DictSchema
,AfterValidatorFunctionSchema
,BeforeValidatorFunctionSchema
,WrapValidatorFunctionSchema
,PlainValidatorFunctionSchema
,WithDefaultSchema
,NullableSchema
,UnionSchema
,TaggedUnionSchema
,ChainSchema
,LaxOrStrictSchema
,JsonOrPythonSchema
,TypedDictSchema
,ModelFieldsSchema
,ModelSchema
,DataclassArgsSchema
,DataclassSchema
,ArgumentsSchema
,CallSchema
,CustomErrorSchema
,JsonSchema
,UrlSchema
,MultiHostUrlSchema
,DefinitionsSchema
,DefinitionReferenceSchema
,UuidSchema
,ComplexSchema
]) – Apydantic-core
CoreSchema. You can ignore this argument and call the handler with a new CoreSchema, wrap this CoreSchema ({'type': 'nullable', 'schema': current_schema}
), or just call the handler with the original schema.handler (
GetJsonSchemaHandler
) – Call into Pydantic’s internal JSON schema generation. This will raise apydantic.errors.PydanticInvalidForJsonSchema
if JSON schema generation fails. Since this gets called byBaseModel.model_json_schema
you can override theschema_generator
argument to that function to change JSON schema generation globally for a type.
- Return type:
- Returns:
A JSON schema, as a Python object.
- __init__(**data)[source]
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 allowself
as a field name.
- __pretty__(fmt, **kwargs)[source]
Used by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.
- __private_attributes__: ClassVar[Dict[str, ModelPrivateAttr]] = {}[source]
Metadata about the private attributes of the model.
- __pydantic_complete__: ClassVar[bool] = True[source]
Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__: ClassVar[CoreSchema] = {'cls': <class 'kittycad.models.selection.OptionMeshByName'>, 'config': {'title': 'OptionMeshByName'}, 'custom_init': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'kittycad.models.selection.OptionMeshByName'>, title=None), <bound method BaseModel.__get_pydantic_json_schema__ of <class 'kittycad.models.selection.OptionMeshByName'>>]}, 'ref': 'kittycad.models.selection.OptionMeshByName:94675536627504', 'root_model': False, 'schema': {'computed_fields': [], 'fields': {'name': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'type': 'str'}, 'type': 'model-field'}, 'type': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'default': 'mesh_by_name', 'schema': {'expected': ['mesh_by_name'], 'type': 'literal'}, 'type': 'default'}, 'type': 'model-field'}}, 'model_name': 'OptionMeshByName', 'type': 'model-fields'}, 'type': 'model'}[source]
The core schema of the model.
- __pydantic_custom_init__: ClassVar[bool] = False[source]
Whether the model has a custom
__init__
method.
- __pydantic_decorators__: ClassVar[_decorators.DecoratorInfos] = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})[source]
Metadata containing the decorators defined on the model. This replaces
Model.__validators__
andModel.__root_validators__
from Pydantic V1.
- __pydantic_extra__: dict[str, Any] | None[source]
A dictionary containing extra values, if [
extra
][pydantic.config.ConfigDict.extra] is set to'allow'
.
- __pydantic_generic_metadata__: ClassVar[_generics.PydanticGenericMetadata] = {'args': (), 'origin': None, 'parameters': ()}[source]
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.
- classmethod __pydantic_init_subclass__(**kwargs)[source]
This is intended to behave just like
__init_subclass__
, but is called byModelMetaclass
only after the class is actually fully initialized. In particular, attributes likemodel_fields
will be present when this is called.This is necessary because
__init_subclass__
will always be called bytype.__new__
, and it would require a prohibitively large refactor to theModelMetaclass
to ensure thattype.__new__
was called in such a manner that the class would already be sufficiently initialized.This will receive the same
kwargs
that would be passed to the standard__init_subclass__
, namely, any kwargs passed to the class definition that aren’t used internally by pydantic.
- __pydantic_parent_namespace__: ClassVar[Dict[str, Any] | None] = None[source]
Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__: ClassVar[None | Literal['model_post_init']] = None[source]
The name of the post-init method for the model, if defined.
- __pydantic_private__: dict[str, Any] | None[source]
Values of private attributes set on the model instance.
- __pydantic_root_model__: ClassVar[bool] = False[source]
Whether the model is a [
RootModel
][pydantic.root_model.RootModel].
- __pydantic_serializer__: ClassVar[SchemaSerializer] = SchemaSerializer(serializer=Model( ModelSerializer { class: Py( 0x0000561b5dbac730, ), serializer: Fields( GeneralFieldsSerializer { fields: { "type": SerField { key_py: Py( 0x00007f1785a3c5a0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f1781c0bbb0, ), ), serializer: Literal( LiteralSerializer { expected_int: {}, expected_str: { "mesh_by_name", }, expected_py: None, name: "literal['mesh_by_name']", }, ), }, ), ), required: true, }, "name": SerField { key_py: Py( 0x00007f1785a3a388, ), alias: None, alias_py: None, serializer: Some( Str( StrSerializer, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 2, }, ), has_extra: false, root_model: false, name: "OptionMeshByName", }, ), definitions=[])[source]
The
pydantic-core
SchemaSerializer
used to dump instances of the model.
- __pydantic_validator__: ClassVar[SchemaValidator | PluggableSchemaValidator] = SchemaValidator(title="OptionMeshByName", validator=Model( ModelValidator { revalidate: Never, validator: ModelFields( ModelFieldsValidator { fields: [ Field { name: "name", lookup_key: Simple { key: "name", py_key: Py( 0x00007f1781cba6d0, ), path: LookupPath( [ S( "name", Py( 0x00007f1781cba730, ), ), ], ), }, name_py: Py( 0x00007f1785a3a388, ), validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), frozen: false, }, Field { name: "type", lookup_key: Simple { key: "type", py_key: Py( 0x00007f1781cba760, ), path: LookupPath( [ S( "type", Py( 0x00007f1781cba790, ), ), ], ), }, name_py: Py( 0x00007f1785a3c5a0, ), validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f1781c0bbb0, ), ), on_error: Raise, validator: Literal( LiteralValidator { lookup: LiteralLookup { expected_bool: None, expected_int: None, expected_str: Some( { "mesh_by_name": 0, }, ), expected_py_dict: None, expected_py_values: None, values: [ Py( 0x00007f1781c0bbb0, ), ], }, expected_repr: "'mesh_by_name'", name: "literal['mesh_by_name']", }, ), validate_default: false, copy_default: false, name: "default[literal['mesh_by_name']]", undefined: Py( 0x00007f1783902350, ), }, ), frozen: false, }, ], model_name: "OptionMeshByName", extra_behavior: Ignore, extras_validator: None, strict: false, from_attributes: false, loc_by_alias: true, }, ), class: Py( 0x0000561b5dbac730, ), post_init: None, frozen: false, custom_init: false, root_model: false, undefined: Py( 0x00007f1783902350, ), name: "OptionMeshByName", }, ), definitions=[], cache_strings=True)[source]
The
pydantic-core
SchemaValidator
used to validate instances of the model.
- __rich_repr__()[source]
Used by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.
- __signature__: ClassVar[Signature] = <Signature (*, name: str, type: Literal['mesh_by_name'] = 'mesh_by_name') -> None>[source]
The synthesized
__init__
[Signature
][inspect.Signature] of the model.
- __slots__ = ('__dict__', '__pydantic_fields_set__', '__pydantic_extra__', '__pydantic_private__')[source]
- copy(*, include=None, exclude=None, update=None, deep=False)[source]
Returns a copy of the model.
- !!! warning “Deprecated”
This method is now deprecated; use
model_copy
instead.
If you need
include
orexclude
, use:`py data = self.model_dump(include=include, exclude=exclude, round_trip=True) data = {**data, **(update or {})} copied = self.model_validate(data) `
- Parameters:
include – Optional set or mapping specifying which fields to include in the copied model.
exclude – Optional set or mapping specifying which fields to exclude in the copied model.
update – Optional dictionary of field-value pairs to override field values in the copied model.
deep – If True, the values of fields that are Pydantic models will be deep-copied.
- Returns:
A copy of the model with included, excluded and updated fields as specified.
- dict(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False)[source]
- json(*, include=None, exclude=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, encoder=PydanticUndefined, models_as_dict=PydanticUndefined, **dumps_kwargs)[source]
- Return type:
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}[source]
A dictionary of computed field names and their corresponding
ComputedFieldInfo
objects.
- model_config: ClassVar[ConfigDict] = {'protected_namespaces': ()}[source]
Configuration for the model, should be a dictionary conforming to [
ConfigDict
][pydantic.config.ConfigDict].
- classmethod model_construct(_fields_set=None, **values)[source]
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 themodel_config.extra
setting on the provided model. That is, ifmodel_config.extra == 'allow'
, then all extra passed values are added to the model instance’s__dict__
and__pydantic_extra__
fields. Ifmodel_config.extra == 'ignore'
(the default), then all extra passed values are ignored. Because no validation is performed with a call tomodel_construct()
, havingmodel_config.extra == 'forbid'
does not result in an error if extra values are passed, but they will be ignored.
- Parameters:
_fields_set (
set
[str
] |None
) – 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 thevalues
argument will be used.values (
Any
) – Trusted or pre-validated data dictionary.
- Return type:
Self
- Returns:
A new instance of the
Model
class with validated data.
- model_copy(*, update=None, deep=False)[source]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
Returns a copy of the model.
- model_dump(*, mode='python', include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)[source]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Parameters:
mode (
Union
[Literal
['json'
,'python'
],str
]) – The mode in whichto_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 (
Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],Mapping
[str
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],None
]) – A set of fields to include in the output.exclude (
Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],Mapping
[str
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],None
]) – A set of fields to exclude from the output.context (
Any
|None
) – Additional context to pass to the serializer.by_alias (
bool
) – Whether to use the field’s alias in the dictionary key if defined.exclude_unset (
bool
) – Whether to exclude fields that have not been explicitly set.exclude_defaults (
bool
) – Whether to exclude fields that are set to their default value.exclude_none (
bool
) – Whether to exclude fields that have a value ofNone
.round_trip (
bool
) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].warnings (
Union
[bool
,Literal
['none'
,'warn'
,'error'
]]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError
][pydantic_core.PydanticSerializationError].serialize_as_any (
bool
) – Whether to serialize fields with duck-typing serialization behavior.
- Return type:
- Returns:
A dictionary representation of the model.
- model_dump_json(*, indent=None, include=None, exclude=None, context=None, by_alias=False, exclude_unset=False, exclude_defaults=False, exclude_none=False, round_trip=False, warnings=True, serialize_as_any=False)[source]
Usage docs: https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
Generates a JSON representation of the model using Pydantic’s
to_json
method.- Parameters:
indent (
int
|None
) – Indentation to use in the JSON output. If None is passed, the output will be compact.include (
Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],Mapping
[str
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],None
]) – Field(s) to include in the JSON output.exclude (
Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],Mapping
[str
,Union
[Set
[int
],Set
[str
],Mapping
[int
,Union
[IncEx,Literal
[True
]]],Mapping
[str
,Union
[IncEx,Literal
[True
]]],Literal
[True
]]],None
]) – Field(s) to exclude from the JSON output.context (
Any
|None
) – Additional context to pass to the serializer.by_alias (
bool
) – Whether to serialize using field aliases.exclude_unset (
bool
) – Whether to exclude fields that have not been explicitly set.exclude_defaults (
bool
) – Whether to exclude fields that are set to their default value.exclude_none (
bool
) – Whether to exclude fields that have a value ofNone
.round_trip (
bool
) – If True, dumped values should be valid as input for non-idempotent types such as Json[T].warnings (
Union
[bool
,Literal
['none'
,'warn'
,'error'
]]) – How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors, “error” raises a [PydanticSerializationError
][pydantic_core.PydanticSerializationError].serialize_as_any (
bool
) – Whether to serialize fields with duck-typing serialization behavior.
- Return type:
- Returns:
A JSON string representation of the model.
- property model_extra: dict[str, Any] | None[source]
Get extra fields set during validation.
- Returns:
A dictionary of extra fields, or
None
ifconfig.extra
is not set to"allow"
.
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'name': FieldInfo(annotation=str, required=True), 'type': FieldInfo(annotation=Literal['mesh_by_name'], required=False, default='mesh_by_name')}[source]
Metadata about the fields defined on the model, mapping of field names to [
FieldInfo
][pydantic.fields.FieldInfo] objects.This replaces
Model.__fields__
from Pydantic V1.
- property model_fields_set: set[str][source]
Returns the set of fields that have been explicitly set on this model instance.
- Returns:
- A set of strings representing the fields that have been set,
i.e. that were not filled from defaults.
- classmethod model_json_schema(by_alias=True, ref_template='#/$defs/{model}', schema_generator=<class 'pydantic.json_schema.GenerateJsonSchema'>, mode='validation')[source]
Generates a JSON schema for a model class.
- Parameters:
by_alias (
bool
) – Whether to use attribute aliases or not.ref_template (
str
) – The reference template.schema_generator (
type
[GenerateJsonSchema
]) – To override the logic used to generate the JSON schema, as a subclass ofGenerateJsonSchema
with your desired modificationsmode (
Literal
['validation'
,'serialization'
]) – The mode in which to generate the schema.
- Return type:
- Returns:
The JSON schema for the given model class.
- classmethod model_parametrized_name(params)[source]
Compute the class name for parametrizations of generic classes.
This method can be overridden to achieve a custom naming scheme for generic BaseModels.
- Parameters:
params (
tuple
[type
[Any
],...
]) – Tuple of types of the class. Given a generic classModel
with 2 type variables and a concrete modelModel[str, int]
, the value(str, int)
would be passed toparams
.- Return type:
- Returns:
String representing the new class where
params
are passed tocls
as type variables.- Raises:
TypeError – Raised when trying to generate concrete names for non-generic models.
- model_post_init(_BaseModel__context)[source]
Override this method to perform additional initialization after
__init__
andmodel_construct
. This is useful if you want to do some validation that requires the entire model to be initialized.- Return type:
- classmethod model_rebuild(*, force=False, raise_errors=True, _parent_namespace_depth=2, _types_namespace=None)[source]
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.
- Parameters:
force (
bool
) – Whether to force the rebuilding of the model schema, defaults toFalse
.raise_errors (
bool
) – Whether to raise errors, defaults toTrue
._parent_namespace_depth (
int
) – The depth level of the parent namespace, defaults to 2._types_namespace (
dict
[str
,Any
] |None
) – The types namespace, defaults toNone
.
- Return type:
- Returns:
Returns
None
if the schema is already “complete” and rebuilding was not required. If rebuilding _was_ required, returnsTrue
if rebuilding was successful, otherwiseFalse
.
- classmethod model_validate(obj, *, strict=None, from_attributes=None, context=None)[source]
Validate a pydantic model instance.
- Parameters:
- Raises:
ValidationError – If the object could not be validated.
- Return type:
Self
- Returns:
The validated model instance.
- classmethod model_validate_json(json_data, *, strict=None, context=None)[source]
Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
Validate the given JSON data against the Pydantic model.
- Parameters:
- Return type:
Self
- Returns:
The validated Pydantic model.
- Raises:
ValidationError – If
json_data
is not a JSON string or the object could not be validated.
- classmethod model_validate_strings(obj, *, strict=None, context=None)[source]
Validate the given object with string data against the Pydantic model.
- classmethod parse_file(path, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)[source]
- Return type:
Self
- classmethod parse_raw(b, *, content_type=None, encoding='utf8', proto=None, allow_pickle=False)[source]
- Return type:
Self