X7ROOT File Manager
Current Path:
/opt/cloudlinux/venv/lib/python3.11/site-packages/pydantic/_internal
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
pydantic
/
_internal
/
📁
..
📄
__init__.py
(0 B)
📁
__pycache__
📄
_config.py
(11.04 KB)
📄
_core_metadata.py
(3.44 KB)
📄
_core_utils.py
(24.24 KB)
📄
_dataclasses.py
(10.46 KB)
📄
_decorators.py
(30.05 KB)
📄
_decorators_v1.py
(6.12 KB)
📄
_discriminated_union.py
(25.61 KB)
📄
_fields.py
(11.62 KB)
📄
_forward_ref.py
(425 B)
📄
_generate_schema.py
(87.89 KB)
📄
_generics.py
(21.65 KB)
📄
_internal_dataclass.py
(207 B)
📄
_known_annotated_metadata.py
(15.89 KB)
📄
_mock_val_ser.py
(4.2 KB)
📄
_model_construction.py
(26.41 KB)
📄
_repr.py
(4.27 KB)
📄
_schema_generation_shared.py
(4.74 KB)
📄
_std_types_schema.py
(28.27 KB)
📄
_typing_extra.py
(16.15 KB)
📄
_utils.py
(11.42 KB)
📄
_validate_call.py
(5.36 KB)
📄
_validators.py
(9.81 KB)
Editing: _core_metadata.py
from __future__ import annotations as _annotations import typing from typing import Any import typing_extensions if typing.TYPE_CHECKING: from ._schema_generation_shared import ( CoreSchemaOrField as CoreSchemaOrField, ) from ._schema_generation_shared import ( GetJsonSchemaFunction, ) class CoreMetadata(typing_extensions.TypedDict, total=False): """A `TypedDict` for holding the metadata dict of the schema. Attributes: pydantic_js_functions: List of JSON schema functions. pydantic_js_prefer_positional_arguments: Whether JSON schema generator will prefer positional over keyword arguments for an 'arguments' schema. """ pydantic_js_functions: list[GetJsonSchemaFunction] pydantic_js_annotation_functions: list[GetJsonSchemaFunction] # If `pydantic_js_prefer_positional_arguments` is True, the JSON schema generator will # prefer positional over keyword arguments for an 'arguments' schema. pydantic_js_prefer_positional_arguments: bool | None pydantic_typed_dict_cls: type[Any] | None # TODO: Consider moving this into the pydantic-core TypedDictSchema class CoreMetadataHandler: """Because the metadata field in pydantic_core is of type `Any`, we can't assume much about its contents. This class is used to interact with the metadata field on a CoreSchema object in a consistent way throughout pydantic. """ __slots__ = ('_schema',) def __init__(self, schema: CoreSchemaOrField): self._schema = schema metadata = schema.get('metadata') if metadata is None: schema['metadata'] = CoreMetadata() elif not isinstance(metadata, dict): raise TypeError(f'CoreSchema metadata should be a dict; got {metadata!r}.') @property def metadata(self) -> CoreMetadata: """Retrieves the metadata dict from the schema, initializing it to a dict if it is None and raises an error if it is not a dict. """ metadata = self._schema.get('metadata') if metadata is None: self._schema['metadata'] = metadata = CoreMetadata() if not isinstance(metadata, dict): raise TypeError(f'CoreSchema metadata should be a dict; got {metadata!r}.') return metadata def build_metadata_dict( *, # force keyword arguments to make it easier to modify this signature in a backwards-compatible way js_functions: list[GetJsonSchemaFunction] | None = None, js_annotation_functions: list[GetJsonSchemaFunction] | None = None, js_prefer_positional_arguments: bool | None = None, typed_dict_cls: type[Any] | None = None, initial_metadata: Any | None = None, ) -> Any: """Builds a dict to use as the metadata field of a CoreSchema object in a manner that is consistent with the CoreMetadataHandler class. """ if initial_metadata is not None and not isinstance(initial_metadata, dict): raise TypeError(f'CoreSchema metadata should be a dict; got {initial_metadata!r}.') metadata = CoreMetadata( pydantic_js_functions=js_functions or [], pydantic_js_annotation_functions=js_annotation_functions or [], pydantic_js_prefer_positional_arguments=js_prefer_positional_arguments, pydantic_typed_dict_cls=typed_dict_cls, ) metadata = {k: v for k, v in metadata.items() if v is not None} if initial_metadata is not None: metadata = {**initial_metadata, **metadata} return metadata
Upload File
Create Folder