pydantic_core
| Use Case | Command | Description |
|---|---|---|
| Validate Python data | SchemaValidator(schema).validate_python(data) | Validate a Python object against a schema |
| Validate JSON string | SchemaValidator(schema).validate_json(json_str) | Validate a JSON string against a schema |
| Validate assignment | SchemaValidator(schema).validate_assignment(obj, field, val) | Validate a single field assignment |
| Serialize to JSON | SchemaSerializer(schema).to_json(obj) | Serialize a Python object to a JSON string |
| Serialize to Python | SchemaSerializer(schema).to_python(obj) | Serialize to Python primitives |
| Custom error | raise PydanticCustomError('my_error', 'Template {value}', {'value': 123}) | Raise a custom validation error |
| Access validation errors | ValidationError.errors() | Get list of error details |
| Build a URL | Url.build(scheme='https', host='example.com') | Construct a parsed URL |
| Convert JSON | from_json(data) | Parse JSON into Python with Pydantic core types |
| Convert to JSON | to_json(value) | Serialize Python to JSON string with full control |
_pydantic_corecore_schemabuiltins.Exception → pydantic_core._pydantic_core.PydanticOmit, pydantic_core._pydantic_core.PydanticUseDefault, pydantic_core._pydantic_core.SchemaErrorbuiltins.ValueError → pydantic_core._pydantic_core.PydanticCustomError, pydantic_core._pydantic_core.PydanticKnownError, pydantic_core._pydantic_core.PydanticSerializationError, pydantic_core._pydantic_core.PydanticSerializationUnexpectedValue, pydantic_core._pydantic_core.ValidationErrorbuiltins.dict → ErrorDetails, InitErrorDetails, pydantic_core.core_schema.CoreConfigbuiltins.object → pydantic_core._pydantic_core.ArgsKwargs, pydantic_core._pydantic_core.MultiHostUrl, pydantic_core._pydantic_core.PydanticUndefinedType, pydantic_core._pydantic_core.SchemaSerializer, pydantic_core._pydantic_core.SchemaValidator, pydantic_core._pydantic_core.Some, pydantic_core._pydantic_core.Urldatetime.tzinfo → pydantic_core._pydantic_core.TzInfoclass ArgsKwargs(builtins.object)
| ArgsKwargs(args, kwargs=None)
Methods defined here:
__eq__(self, value, /) — Return self==value.__ge__(self, value, /) — Return self>=value.__gt__(self, value, /) — Return self>value.__le__(self, value, /) — Return self<=value.__lt__(self, value, /) — Return self<value.__ne__(self, value, /) — Return self!=value.__repr__(self, /) — Return repr(self).Static methods defined here:
__new__(*args, **kwargs) from builtins.type — Create and return a new object. See help(type) for accurate signature.Data descriptors defined here:
argskwargsData and other attributes defined here:
__hash__ = Noneclass CoreConfig(builtins.dict)
Base class for schema configuration options.
Attributes:
title: The name of the configuration.strict: Whether the configuration should strictly adhere to specified rules.extra_fields_behavior: The behavior for handling extra fields.typed_dict_total: Whether the TypedDict should be considered total. Default is True.from_attributes: Whether to use attributes for models, dataclasses, and tagged union keys.loc_by_alias: Whether to use the used alias (or first alias for "field required" errors) instead of field_names to construct error locs. Default is True.revalidate_instances: Whether instances of models and dataclasses should re-validate. Default is 'never'.validate_default: Whether to validate default values during validation. Default is False.str_max_length: The maximum length for string fields.str_min_length: The minimum length for string fields.str_strip_whitespace: Whether to strip whitespace from string fields.str_to_lower: Whether to convert string fields to lowercase.str_to_upper: Whether to convert string fields to uppercase.allow_inf_nan: Whether to allow infinity and NaN values for float fields. Default is True.ser_json_timedelta: The serialization option for timedelta values. Default is 'iso8601'. Note that if ser_json_temporal is set, this param will be ignored.ser_json_temporal: The serialization option for datetime like values. Default is 'iso8601'. The types this covers are datetime, date, time and timedelta. If this is set, it will take precedence over ser_json_timedelta.ser_json_bytes: The serialization option for bytes values. Default is 'utf8'.ser_json_inf_nan: The serialization option for infinity and NaN values in float fields. Default is 'null'.val_json_bytes: The validation option for bytes values, complementing ser_json_bytes. Default is 'utf8'.hide_input_in_errors: Whether to hide input data from ValidationError representation.validation_error_cause: Whether to add user-python excs to the __cause__ of a ValidationError. Requires exceptiongroup backport pre Python 3.11.coerce_numbers_to_str: Whether to enable coercion of any Number type to str (not applicable in strict mode).regex_engine: The regex engine to use for regex pattern validation. Default is 'rust-regex'. See StringSchema.cache_strings: Whether to cache strings. Default is True, True or 'all' is required to cache strings during general validation since validators don't know if they're in a key or a value.validate_by_alias: Whether to use the field's alias when validating against the provided input data. Default is True.validate_by_name: Whether to use the field's name when validating against the provided input data. Default is False. Replacement for populate_by_name.serialize_by_alias: Whether to serialize by alias. Default is False, expected to change to True in V3.polymorphic_serialization: Whether to enable polymorphic serialization for models and dataclasses. Default is False.url_preserve_empty_path: Whether to preserve empty URL paths when validating values for a URL type. Defaults to False.Method resolution order:
CoreConfigbuiltins.dictbuiltins.objectData descriptors defined here:
__dict__ — dictionary for instance variables (if defined)__weakref__ — list of weak references to the object (if defined)Data and other attributes defined here: __annotations__, __closed__, __extra_items__, __mutable_keys__, __optional_keys__, __orig_bases__, __readonly_keys__, __required_keys__, __total__
Methods inherited from builtins.dict:
__contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __init__, __ior__, __iter__, __le__, __len__, __lt__, __ne__, __or__, __repr__, __reversed__, __ror__, __setitem__, __sizeof__, clear, copy, get, items, keys, pop, popitem, setdefault, update, valuesClass methods inherited from builtins.dict: __class_getitem__, fromkeys
Static methods inherited: __new__; __hash__ = None
class ErrorDetails(builtins.dict)
Method resolution order: ErrorDetails → builtins.dict → builtins.object
Data descriptors: __dict__, __weakref__
Required keys: ctx, input, loc, msg, type, url (all mutable). No optional keys. __total__ = True.
Inherited dict methods: __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __init__, __ior__, __iter__, __le__, __len__, __lt__, __ne__, __or__, __repr__, __reversed__, __ror__, __setitem__, __sizeof__, clear, copy, get, items, keys, pop, popitem, setdefault, update, values; __class_getitem__, fromkeys.
class InitErrorDetails(builtins.dict)
Similar to ErrorDetails but required keys are ctx, input, loc, type (all mutable). __total__ = True.
Inherited dict methods as above.
class MultiHostUrl(builtins.object)
| MultiHostUrl(url, *, preserve_empty_path=False)
Methods defined here:
__bool__ — True if self else False__deepcopy____eq__ — Return self==value.__ge__ — Return self>=value.__getnewargs____gt__ — Return self>value.__hash__ — Return hash(self).__le__ — Return self<=value.__lt__ — Return self<value.__ne__ — Return self!=value.__repr__ — Return repr(self).__str__ — Return str(self).hosts()query_params()unicode_string()Class methods defined here:
build(*, scheme, hosts=None, path=None, query=None, fragment=None, host=None, username=None, password=None, port=None)Static methods: __new__
Data descriptors: fragment, path, query, scheme
class PydanticCustomError(builtins.ValueError)
| PydanticCustomError(error_type, message_template, context=None, /)
Methods:
__repr__, __str__, message()Data descriptors: context, message_template, type
Inherited from ValueError: __init__; from BaseException: __delattr__, __getattribute__, __reduce__, __setattr__, __setstate__, with_traceback, args, __cause__, __context__, __dict__, __suppress_context__, __traceback__
class PydanticKnownError(builtins.ValueError)
| PydanticKnownError(error_type, context=None, /)
Methods: __repr__, __str__, message()
Data descriptors: context, message_template, type
Inherited as above.
class PydanticOmit(builtins.Exception)
Methods: __repr__, __str__; inherited __init__, etc.
class PydanticSerializationError(builtins.ValueError)
| PydanticSerializationError(message, /)
Methods: __repr__, __str__; inherited __init__ and base exception methods.
class PydanticSerializationUnexpectedValue(builtins.ValueError)
| PydanticSerializationUnexpectedValue(message=None, field_name=None, field_type=None, input_value=None, /)
Methods: __repr__, __str__; inherited as above.
class PydanticUndefinedType(builtins.object)
Methods: __copy__, __deepcopy__, __reduce__, __repr__, __new__, new()
class PydanticUseDefault(builtins.Exception)
Methods: __repr__, __str__; inherited __init__ and base exception methods.
class SchemaError(builtins.Exception)
| SchemaError(message)
Methods: __repr__, __str__, error_count(), errors(); inherited base exception methods.
class SchemaSerializer(builtins.object)
| SchemaSerializer(schema, config=None, _use_prebuilt=True)
Methods:
__reduce__ — Helper for pickle.__repr__ — Return repr(self).to_json(self, /, value, *, indent=None, ensure_ascii=False, include=None, exclude=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=Ellipsis, fallback=None, serialize_as_any=False, polymorphic_serialization=None, context=None)to_python(self, /, value, *, mode=None, include=None, exclude=None, by_alias=None, exclude_unset=False, exclude_defaults=False, exclude_none=False, exclude_computed_fields=False, round_trip=False, warnings=Ellipsis, fallback=None, serialize_as_any=False, polymorphic_serialization=None, context=None)Static method: __new__
class SchemaValidator(builtins.object)
| SchemaValidator(schema, config=None, _use_prebuilt=True)
Methods:
__reduce__ — Helper for pickle.__repr__ — Return repr(self).get_default_value(self, /, *, strict=None, context=None)isinstance_python(self, /, input, *, strict=None, extra=None, from_attributes=None, context=None, self_instance=None, by_alias=None, by_name=None)validate_assignment(self, /, obj, field_name, field_value, *, strict=None, extra=None, from_attributes=None, context=None, by_alias=None, by_name=None)validate_json(self, /, input, *, strict=None, extra=None, context=None, self_instance=None, allow_partial=Ellipsis, by_alias=None, by_name=None)validate_python(self, /, input, *, strict=None, extra=None, from_attributes=None, context=None, self_instance=None, allow_partial=Ellipsis, by_alias=None, by_name=None)validate_strings(self, /, input, *, strict=None, extra=None, context=None, allow_partial=Ellipsis, by_alias=None, by_name=None)Static method: __new__
Data descriptor: title
class Some(builtins.object)
| Some(value)
Methods: __repr__; class method: __class_getitem__; static: __new__; data descriptor: value; __match_args__ = ('value',)
class TzInfo(datetime.tzinfo)
| TzInfo(seconds=0.0)
Methods: __deepcopy__, __eq__, __ge__, __gt__, __hash__, __le__, __lt__, __ne__, __reduce__, __repr__, __str__, dst(dt), fromutc(dt), tzname(dt), utcoffset(dt); inherited __getattribute__.
class Url(builtins.object)
| Url(url, *, preserve_empty_path=False)
Methods: __bool__, __deepcopy__, __eq__, __ge__, __getnewargs__, __gt__, __hash__, __le__, __lt__, __ne__, __repr__, __str__, query_params(), unicode_host(), unicode_string(); class method: build(*, scheme, host, username=None, password=None, port=None, path=None, query=None, fragment=None); static: __new__; descriptors: fragment, host, password, path, port, query, scheme, username
class ValidationError(builtins.ValueError)
| ValidationError(title, line_errors, input_type='python', hide_input=False)
Methods: __reduce__, __repr__, __str__, error_count(), errors(*, include_url=True, include_context=True, include_input=True), json(*, indent=None, include_url=True, include_context=True, include_input=True); class method: from_exception_data(title, line_errors, input_type='python', hide_input=False); static: __new__; descriptor: title. Inherited: __init__, base exception methods.
from_json(data, *, allow_inf_nan=True, cache_strings=Ellipsis, allow_partial=Ellipsis)to_json(value, *, indent=None, ensure_ascii=False, include=None, exclude=None, by_alias=True, exclude_none=False, round_trip=False, timedelta_mode='iso8601', temporal_mode='iso8601', bytes_mode='utf8', inf_nan_mode='constants', serialize_unknown=False, fallback=None, serialize_as_any=False, polymorphic_serialization=None, context=None)to_jsonable_python(value, *, include=None, exclude=None, by_alias=True, exclude_none=False, round_trip=False, timedelta_mode='iso8601', temporal_mode='iso8601', bytes_mode='utf8', inf_nan_mode='constants', serialize_unknown=False, fallback=None, serialize_as_any=False, polymorphic_serialization=None, context=None)CoreSchema = typing.Union[pydantic_core.core_schema.InvalidSchema, ...]CoreSchemaType = typing.Literal['invalid', 'any', 'none', 'bool', ...]PydanticUndefined = PydanticUndefined__all__ = ['__version__', 'UNSET', 'CoreConfig', 'CoreSchema', 'CoreSchemaType', ...]2.46.4
/home/chedong/.local/lib/python3.10/site-packages/pydantic_core/__init__.py
Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 11:08 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format