From c0f177b49759b557b961a341fd4ec51c24478bce Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 8 Feb 2023 13:03:39 +0100 Subject: [PATCH 1/3] Update pyo3 to 0.18.1 --- Cargo.lock | 64 +++++++++++++++++++++++++++++++++--------------------- Cargo.toml | 8 ++----- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86f0eab7f..7c610daa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ahash" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "getrandom", @@ -43,9 +43,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cc" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "cfg-if" @@ -93,9 +93,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "idna" @@ -119,9 +119,9 @@ dependencies = [ [[package]] name = "indoc" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2d6f23ffea9d7e76c53eee25dfb67bcd8fde7f1198b0855350698c9f07c780" +checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "itoa" @@ -197,9 +197,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ef8814b5c993410bb3adfad7a5ed269563e4a2f90c41f5d85be7fb47133bf" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", @@ -216,9 +216,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -248,7 +248,8 @@ dependencies = [ [[package]] name = "pyo3" version = "0.18.1" -source = "git+https://github.com/PyO3/pyo3?branch=release-0.18.1#184c085f54deced70d630a388788fbe3a644b492" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06a3d8e8a46ab2738109347433cb7b96dffda2e4a218b03ef27090238886b147" dependencies = [ "cfg-if", "indoc", @@ -264,7 +265,8 @@ dependencies = [ [[package]] name = "pyo3-build-config" version = "0.18.1" -source = "git+https://github.com/PyO3/pyo3?branch=release-0.18.1#184c085f54deced70d630a388788fbe3a644b492" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75439f995d07ddfad42b192dfcf3bc66a7ecfd8b4a1f5f6f046aa5c2c5d7677d" dependencies = [ "once_cell", "target-lexicon", @@ -273,7 +275,8 @@ dependencies = [ [[package]] name = "pyo3-ffi" version = "0.18.1" -source = "git+https://github.com/PyO3/pyo3?branch=release-0.18.1#184c085f54deced70d630a388788fbe3a644b492" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839526a5c07a17ff44823679b68add4a58004de00512a95b6c1c98a6dcac0ee5" dependencies = [ "libc", "pyo3-build-config", @@ -282,7 +285,8 @@ dependencies = [ [[package]] name = "pyo3-macros" version = "0.18.1" -source = "git+https://github.com/PyO3/pyo3?branch=release-0.18.1#184c085f54deced70d630a388788fbe3a644b492" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd44cf207476c6a9760c4653559be4f206efafb924d3e4cbf2721475fc0d6cc5" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -293,7 +297,8 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" version = "0.18.1" -source = "git+https://github.com/PyO3/pyo3?branch=release-0.18.1#184c085f54deced70d630a388788fbe3a644b492" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1f43d8e30460f36350d18631ccf85ded64c059829208fe680904c65bcd0a4c" dependencies = [ "proc-macro2", "quote", @@ -361,9 +366,9 @@ checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "7434af0dc1cbd59268aa98b4c22c131c0584d2232f6fb166efb993e2832e896a" dependencies = [ "indexmap", "itoa", @@ -437,15 +442,15 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" [[package]] name = "unicode-ident" @@ -493,9 +498,18 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", diff --git a/Cargo.toml b/Cargo.toml index 77a57a2ec..36c8d223a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,9 +26,7 @@ include = [ ] [dependencies] -# required since `Py_Ellipsis` fails on windows, see https://github.com/PyO3/pyo3/pull/2911 -pyo3 = { git = "https://github.com/PyO3/pyo3", branch = "release-0.18.1" } -#pyo3 = "0.18.0" +pyo3 = "0.18.1" regex = "1.6.0" strum = { version = "0.24.1", features = ["derive"] } strum_macros = "0.24.3" @@ -67,6 +65,4 @@ strip = true [build-dependencies] version_check = "0.9.4" # used where logic has to be version/distribution specific, e.g. pypy -# FIXME change when `pyo3` above is updated -pyo3-build-config = { git = "https://github.com/PyO3/pyo3", branch = "release-0.18.1" } -#pyo3 = "0.18.0" +pyo3-build-config = "0.18.1" From 404a698ece52e89105357055d00dba03e77f9089 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 8 Feb 2023 00:49:22 +0100 Subject: [PATCH 2/3] Add base class for CoreSchema TypedDict --- pydantic_core/core_schema.py | 86 +++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/pydantic_core/core_schema.py b/pydantic_core/core_schema.py index ea2b45400..590be3074 100644 --- a/pydantic_core/core_schema.py +++ b/pydantic_core/core_schema.py @@ -281,7 +281,11 @@ def model_ser_schema(cls: Type[Any], schema: CoreSchema) -> ModelSerSchema: ] -class AnySchema(TypedDict, total=False): +class CoreSchemaBase(TypedDict): + ... + + +class AnySchema(CoreSchemaBase, total=False): type: Required[Literal['any']] ref: str extra: Any @@ -307,7 +311,7 @@ def any_schema(*, ref: str | None = None, extra: Any = None, serialization: SerS return dict_not_none(type='any', ref=ref, extra=extra, serialization=serialization) -class NoneSchema(TypedDict, total=False): +class NoneSchema(CoreSchemaBase, total=False): type: Required[Literal['none']] ref: str extra: Any @@ -333,7 +337,7 @@ def none_schema(*, ref: str | None = None, extra: Any = None, serialization: Ser return dict_not_none(type='none', ref=ref, extra=extra, serialization=serialization) -class BoolSchema(TypedDict, total=False): +class BoolSchema(CoreSchemaBase, total=False): type: Required[Literal['bool']] strict: bool ref: str @@ -363,7 +367,7 @@ def bool_schema( return dict_not_none(type='bool', strict=strict, ref=ref, extra=extra, serialization=serialization) -class IntSchema(TypedDict, total=False): +class IntSchema(CoreSchemaBase, total=False): type: Required[Literal['int']] multiple_of: int le: int @@ -423,7 +427,7 @@ def int_schema( ) -class FloatSchema(TypedDict, total=False): +class FloatSchema(CoreSchemaBase, total=False): type: Required[Literal['float']] allow_inf_nan: bool # whether 'NaN', '+inf', '-inf' should be forbidden. default: True multiple_of: float @@ -487,7 +491,7 @@ def float_schema( ) -class StringSchema(TypedDict, total=False): +class StringSchema(CoreSchemaBase, total=False): type: Required[Literal['str']] pattern: str max_length: int @@ -551,7 +555,7 @@ def str_schema( ) -class BytesSchema(TypedDict, total=False): +class BytesSchema(CoreSchemaBase, total=False): type: Required[Literal['bytes']] max_length: int min_length: int @@ -599,7 +603,7 @@ def bytes_schema( ) -class DateSchema(TypedDict, total=False): +class DateSchema(CoreSchemaBase, total=False): type: Required[Literal['date']] strict: bool le: date @@ -666,7 +670,7 @@ def date_schema( ) -class TimeSchema(TypedDict, total=False): +class TimeSchema(CoreSchemaBase, total=False): type: Required[Literal['time']] strict: bool le: time @@ -715,7 +719,7 @@ def time_schema( ) -class DatetimeSchema(TypedDict, total=False): +class DatetimeSchema(CoreSchemaBase, total=False): type: Required[Literal['datetime']] strict: bool le: datetime @@ -787,7 +791,7 @@ def datetime_schema( ) -class TimedeltaSchema(TypedDict, total=False): +class TimedeltaSchema(CoreSchemaBase, total=False): type: Required[Literal['timedelta']] strict: bool le: timedelta @@ -836,7 +840,7 @@ def timedelta_schema( ) -class LiteralSchema(TypedDict, total=False): +class LiteralSchema(CoreSchemaBase, total=False): type: Required[Literal['literal']] expected: Required[List[Any]] ref: str @@ -870,7 +874,7 @@ def literal_schema( JsonType = Literal['null', 'bool', 'int', 'float', 'str', 'list', 'dict'] -class IsInstanceSchema(TypedDict, total=False): +class IsInstanceSchema(CoreSchemaBase, total=False): type: Required[Literal['is-instance']] cls: Required[Any] cls_repr: str @@ -927,7 +931,7 @@ class A: ) -class IsSubclassSchema(TypedDict, total=False): +class IsSubclassSchema(CoreSchemaBase, total=False): type: Required[Literal['is-subclass']] cls: Required[Type[Any]] cls_repr: str @@ -973,7 +977,7 @@ class B(A): ) -class CallableSchema(TypedDict, total=False): +class CallableSchema(CoreSchemaBase, total=False): type: Required[Literal['callable']] ref: str extra: Any @@ -1014,7 +1018,7 @@ def filter_seq_schema(*, include: Set[int] | None = None, exclude: Set[int] | No IncExSeqOrElseSerSchema = Union[IncExSeqSerSchema, SerSchema] -class ListSchema(TypedDict, total=False): +class ListSchema(CoreSchemaBase, total=False): type: Required[Literal['list']] items_schema: CoreSchema min_length: int @@ -1070,7 +1074,7 @@ def list_schema( ) -class TuplePositionalSchema(TypedDict, total=False): +class TuplePositionalSchema(CoreSchemaBase, total=False): type: Required[Literal['tuple']] mode: Required[Literal['positional']] items_schema: Required[List[CoreSchema]] @@ -1119,7 +1123,7 @@ def tuple_positional_schema( ) -class TupleVariableSchema(TypedDict, total=False): +class TupleVariableSchema(CoreSchemaBase, total=False): type: Required[Literal['tuple']] mode: Literal['variable'] items_schema: CoreSchema @@ -1173,7 +1177,7 @@ def tuple_variable_schema( ) -class SetSchema(TypedDict, total=False): +class SetSchema(CoreSchemaBase, total=False): type: Required[Literal['set']] items_schema: CoreSchema min_length: int @@ -1229,7 +1233,7 @@ def set_schema( ) -class FrozenSetSchema(TypedDict, total=False): +class FrozenSetSchema(CoreSchemaBase, total=False): type: Required[Literal['frozenset']] items_schema: CoreSchema min_length: int @@ -1285,7 +1289,7 @@ def frozenset_schema( ) -class GeneratorSchema(TypedDict, total=False): +class GeneratorSchema(CoreSchemaBase, total=False): type: Required[Literal['generator']] items_schema: CoreSchema max_length: int @@ -1350,7 +1354,7 @@ def filter_dict_schema(*, include: IncExDict | None = None, exclude: IncExDict | IncExDictOrElseSerSchema = Union[IncExDictSerSchema, SerSchema] -class DictSchema(TypedDict, total=False): +class DictSchema(CoreSchemaBase, total=False): type: Required[Literal['dict']] keys_schema: CoreSchema # default: AnySchema values_schema: CoreSchema # default: AnySchema @@ -1415,7 +1419,7 @@ def __call__( ... -class FunctionSchema(TypedDict, total=False): +class FunctionSchema(CoreSchemaBase, total=False): type: Required[Literal['function']] mode: Required[Literal['before', 'after']] function: Required[ValidatorFunction] @@ -1528,7 +1532,7 @@ def __call__( ... -class FunctionWrapSchema(TypedDict, total=False): +class FunctionWrapSchema(CoreSchemaBase, total=False): type: Required[Literal['function']] mode: Required[Literal['wrap']] function: Required[WrapValidatorFunction] @@ -1580,7 +1584,7 @@ def fn(v: str, *, validator, **kwargs) -> str: ) -class FunctionPlainSchema(TypedDict, total=False): +class FunctionPlainSchema(CoreSchemaBase, total=False): type: Required[Literal['function']] mode: Required[Literal['plain']] function: Required[ValidatorFunction] @@ -1618,7 +1622,7 @@ def fn(v: str, **kwargs) -> str: ) -class WithDefaultSchema(TypedDict, total=False): +class WithDefaultSchema(CoreSchemaBase, total=False): type: Required[Literal['default']] schema: Required[CoreSchema] default: Any @@ -1682,7 +1686,7 @@ def with_default_schema( return s -class NullableSchema(TypedDict, total=False): +class NullableSchema(CoreSchemaBase, total=False): type: Required[Literal['nullable']] schema: Required[CoreSchema] strict: bool @@ -1721,7 +1725,7 @@ def nullable_schema( ) -class UnionSchema(TypedDict, total=False): +class UnionSchema(CoreSchemaBase, total=False): type: Required[Literal['union']] choices: Required[List[CoreSchema]] # default true, whether to automatically collapse unions with one element to the inner validator @@ -1782,7 +1786,7 @@ def union_schema( ) -class TaggedUnionSchema(TypedDict, total=False): +class TaggedUnionSchema(CoreSchemaBase, total=False): type: Required[Literal['tagged-union']] choices: Required[Dict[str, Union[str, CoreSchema]]] discriminator: Required[ @@ -1863,7 +1867,7 @@ def tagged_union_schema( ) -class ChainSchema(TypedDict, total=False): +class ChainSchema(CoreSchemaBase, total=False): type: Required[Literal['chain']] steps: Required[List[CoreSchema]] ref: str @@ -1899,7 +1903,7 @@ def fn(v: str, **kwargs) -> str: return dict_not_none(type='chain', steps=steps, ref=ref, extra=extra, serialization=serialization) -class LaxOrStrictSchema(TypedDict, total=False): +class LaxOrStrictSchema(CoreSchemaBase, total=False): type: Required[Literal['lax-or-strict']] lax_schema: Required[CoreSchema] strict_schema: Required[CoreSchema] @@ -1959,7 +1963,7 @@ def fn(v: str, **kwargs) -> str: ) -class TypedDictField(TypedDict, total=False): +class TypedDictField(CoreSchemaBase, total=False): schema: Required[CoreSchema] required: bool validation_alias: Union[str, List[Union[str, int]], List[List[Union[str, int]]]] @@ -2001,7 +2005,7 @@ def typed_dict_field( ) -class TypedDictSchema(TypedDict, total=False): +class TypedDictSchema(CoreSchemaBase, total=False): type: Required[Literal['typed-dict']] fields: Required[Dict[str, TypedDictField]] strict: bool @@ -2071,7 +2075,7 @@ def typed_dict_schema( ) -class ModelSchema(TypedDict, total=False): +class ModelSchema(CoreSchemaBase, total=False): type: Required[Literal['model']] cls: Required[Type[Any]] schema: Required[CoreSchema] @@ -2174,7 +2178,7 @@ def arguments_parameter( return dict_not_none(name=name, schema=schema, mode=mode, alias=alias) -class ArgumentsSchema(TypedDict, total=False): +class ArgumentsSchema(CoreSchemaBase, total=False): type: Required[Literal['arguments']] arguments_schema: Required[List[ArgumentsParameter]] populate_by_name: bool @@ -2227,7 +2231,7 @@ def arguments_schema( ) -class CallSchema(TypedDict, total=False): +class CallSchema(CoreSchemaBase, total=False): type: Required[Literal['call']] arguments_schema: Required[CoreSchema] function: Required[Callable[..., Any]] @@ -2283,7 +2287,7 @@ def call_schema( ) -class RecursiveReferenceSchema(TypedDict, total=False): +class RecursiveReferenceSchema(CoreSchemaBase, total=False): type: Required[Literal['recursive-ref']] schema_ref: Required[str] extra: Any @@ -2312,7 +2316,7 @@ def recursive_reference_schema( return dict_not_none(type='recursive-ref', schema_ref=schema_ref, extra=extra, serialization=serialization) -class CustomErrorSchema(TypedDict, total=False): +class CustomErrorSchema(CoreSchemaBase, total=False): type: Required[Literal['custom-error']] schema: Required[CoreSchema] custom_error_type: Required[str] @@ -2366,7 +2370,7 @@ def custom_error_schema( ) -class JsonSchema(TypedDict, total=False): +class JsonSchema(CoreSchemaBase, total=False): type: Required[Literal['json']] schema: CoreSchema ref: str @@ -2414,7 +2418,7 @@ class MyModel: return dict_not_none(type='json', schema=schema, ref=ref, extra=extra, serialization=serialization) -class UrlSchema(TypedDict, total=False): +class UrlSchema(CoreSchemaBase, total=False): type: Required[Literal['url']] max_length: int allowed_schemes: List[str] @@ -2479,7 +2483,7 @@ def url_schema( ) -class MultiHostUrlSchema(TypedDict, total=False): +class MultiHostUrlSchema(CoreSchemaBase, total=False): type: Required[Literal['multi-host-url']] max_length: int allowed_schemes: List[str] From 54f4a48e0c9e8bb86c12affb42841d9cc0e52691 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 8 Feb 2023 00:58:54 +0100 Subject: [PATCH 3/3] Replace recursive CoreSchema types --- generate_self_schema.py | 10 +++--- pydantic_core/core_schema.py | 60 ++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/generate_self_schema.py b/generate_self_schema.py index 87fdcd09c..ffa2bcf97 100644 --- a/generate_self_schema.py +++ b/generate_self_schema.py @@ -122,14 +122,14 @@ def type_dict_schema(typed_dict) -> dict[str, Any]: # noqa: C901 if matched: required = True - if 'CoreSchema' == fr_arg or re.search('[^a-zA-Z]CoreSchema', fr_arg): - if fr_arg == 'CoreSchema': + if 'CoreSchemaBase' == fr_arg or re.search('[^a-zA-Z]CoreSchemaBase', fr_arg): + if fr_arg == 'CoreSchemaBase': schema = schema_ref_validator - elif fr_arg == 'List[CoreSchema]': + elif fr_arg == 'List[CoreSchemaBase]': schema = {'type': 'list', 'items_schema': schema_ref_validator} - elif fr_arg == 'Dict[str, CoreSchema]': + elif fr_arg == 'Dict[str, CoreSchemaBase]': schema = {'type': 'dict', 'keys_schema': {'type': 'str'}, 'values_schema': schema_ref_validator} - elif fr_arg == 'Dict[str, Union[str, CoreSchema]]': + elif fr_arg == 'Dict[str, Union[str, CoreSchemaBase]]': schema = { 'type': 'dict', 'keys_schema': {'type': 'str'}, diff --git a/pydantic_core/core_schema.py b/pydantic_core/core_schema.py index 590be3074..b1670c6f4 100644 --- a/pydantic_core/core_schema.py +++ b/pydantic_core/core_schema.py @@ -191,7 +191,7 @@ def __call__(self, __input_value: Any, __serializer: SerializeWrapHandler, __inf class FunctionWrapSerSchema(TypedDict, total=False): type: Required[Literal['function-wrap']] function: Required[SerializeWrapFunction] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] json_return_type: JsonReturnTypes when_used: WhenUsed # default: 'always' @@ -262,7 +262,7 @@ def to_string_ser_schema(*, when_used: WhenUsed = 'json-unless-none') -> ToStrin class ModelSerSchema(TypedDict, total=False): type: Required[Literal['model']] cls: Required[Type[Any]] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] def model_ser_schema(cls: Type[Any], schema: CoreSchema) -> ModelSerSchema: @@ -1020,7 +1020,7 @@ def filter_seq_schema(*, include: Set[int] | None = None, exclude: Set[int] | No class ListSchema(CoreSchemaBase, total=False): type: Required[Literal['list']] - items_schema: CoreSchema + items_schema: CoreSchemaBase min_length: int max_length: int strict: bool @@ -1077,8 +1077,8 @@ def list_schema( class TuplePositionalSchema(CoreSchemaBase, total=False): type: Required[Literal['tuple']] mode: Required[Literal['positional']] - items_schema: Required[List[CoreSchema]] - extra_schema: CoreSchema + items_schema: Required[List[CoreSchemaBase]] + extra_schema: CoreSchemaBase strict: bool ref: str extra: Any @@ -1126,7 +1126,7 @@ def tuple_positional_schema( class TupleVariableSchema(CoreSchemaBase, total=False): type: Required[Literal['tuple']] mode: Literal['variable'] - items_schema: CoreSchema + items_schema: CoreSchemaBase min_length: int max_length: int strict: bool @@ -1179,7 +1179,7 @@ def tuple_variable_schema( class SetSchema(CoreSchemaBase, total=False): type: Required[Literal['set']] - items_schema: CoreSchema + items_schema: CoreSchemaBase min_length: int max_length: int generator_max_length: int @@ -1235,7 +1235,7 @@ def set_schema( class FrozenSetSchema(CoreSchemaBase, total=False): type: Required[Literal['frozenset']] - items_schema: CoreSchema + items_schema: CoreSchemaBase min_length: int max_length: int generator_max_length: int @@ -1291,7 +1291,7 @@ def frozenset_schema( class GeneratorSchema(CoreSchemaBase, total=False): type: Required[Literal['generator']] - items_schema: CoreSchema + items_schema: CoreSchemaBase max_length: int ref: str extra: Any @@ -1356,8 +1356,8 @@ def filter_dict_schema(*, include: IncExDict | None = None, exclude: IncExDict | class DictSchema(CoreSchemaBase, total=False): type: Required[Literal['dict']] - keys_schema: CoreSchema # default: AnySchema - values_schema: CoreSchema # default: AnySchema + keys_schema: CoreSchemaBase # default: AnySchema + values_schema: CoreSchemaBase # default: AnySchema min_length: int max_length: int strict: bool @@ -1423,7 +1423,7 @@ class FunctionSchema(CoreSchemaBase, total=False): type: Required[Literal['function']] mode: Required[Literal['before', 'after']] function: Required[ValidatorFunction] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] ref: str extra: Any serialization: SerSchema @@ -1536,7 +1536,7 @@ class FunctionWrapSchema(CoreSchemaBase, total=False): type: Required[Literal['function']] mode: Required[Literal['wrap']] function: Required[WrapValidatorFunction] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] ref: str extra: Any serialization: SerSchema @@ -1624,7 +1624,7 @@ def fn(v: str, **kwargs) -> str: class WithDefaultSchema(CoreSchemaBase, total=False): type: Required[Literal['default']] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] default: Any default_factory: Callable[[], Any] on_error: Literal['raise', 'omit', 'default'] # default: 'raise' @@ -1688,7 +1688,7 @@ def with_default_schema( class NullableSchema(CoreSchemaBase, total=False): type: Required[Literal['nullable']] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] strict: bool ref: str extra: Any @@ -1727,7 +1727,7 @@ def nullable_schema( class UnionSchema(CoreSchemaBase, total=False): type: Required[Literal['union']] - choices: Required[List[CoreSchema]] + choices: Required[List[CoreSchemaBase]] # default true, whether to automatically collapse unions with one element to the inner validator auto_collapse: bool custom_error_type: str @@ -1788,7 +1788,7 @@ def union_schema( class TaggedUnionSchema(CoreSchemaBase, total=False): type: Required[Literal['tagged-union']] - choices: Required[Dict[str, Union[str, CoreSchema]]] + choices: Required[Dict[str, Union[str, CoreSchemaBase]]] discriminator: Required[ Union[str, List[Union[str, int]], List[List[Union[str, int]]], Callable[[Any], Optional[str]]] ] @@ -1869,7 +1869,7 @@ def tagged_union_schema( class ChainSchema(CoreSchemaBase, total=False): type: Required[Literal['chain']] - steps: Required[List[CoreSchema]] + steps: Required[List[CoreSchemaBase]] ref: str extra: Any serialization: SerSchema @@ -1905,8 +1905,8 @@ def fn(v: str, **kwargs) -> str: class LaxOrStrictSchema(CoreSchemaBase, total=False): type: Required[Literal['lax-or-strict']] - lax_schema: Required[CoreSchema] - strict_schema: Required[CoreSchema] + lax_schema: Required[CoreSchemaBase] + strict_schema: Required[CoreSchemaBase] strict: bool ref: str extra: Any @@ -1964,7 +1964,7 @@ def fn(v: str, **kwargs) -> str: class TypedDictField(CoreSchemaBase, total=False): - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] required: bool validation_alias: Union[str, List[Union[str, int]], List[List[Union[str, int]]]] serialization_alias: str @@ -2009,7 +2009,7 @@ class TypedDictSchema(CoreSchemaBase, total=False): type: Required[Literal['typed-dict']] fields: Required[Dict[str, TypedDictField]] strict: bool - extra_validator: CoreSchema + extra_validator: CoreSchemaBase return_fields_set: bool # all these values can be set via config, equivalent fields have `typed_dict_` prefix extra_behavior: Literal['allow', 'forbid', 'ignore'] @@ -2078,7 +2078,7 @@ def typed_dict_schema( class ModelSchema(CoreSchemaBase, total=False): type: Required[Literal['model']] cls: Required[Type[Any]] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] call_after_init: str strict: bool config: CoreConfig @@ -2149,7 +2149,7 @@ class MyModel: class ArgumentsParameter(TypedDict, total=False): name: Required[str] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] mode: Literal['positional_only', 'positional_or_keyword', 'keyword_only'] # default positional_or_keyword alias: Union[str, List[Union[str, int]], List[List[Union[str, int]]]] @@ -2182,8 +2182,8 @@ class ArgumentsSchema(CoreSchemaBase, total=False): type: Required[Literal['arguments']] arguments_schema: Required[List[ArgumentsParameter]] populate_by_name: bool - var_args_schema: CoreSchema - var_kwargs_schema: CoreSchema + var_args_schema: CoreSchemaBase + var_kwargs_schema: CoreSchemaBase ref: str extra: Any serialization: SerSchema @@ -2233,9 +2233,9 @@ def arguments_schema( class CallSchema(CoreSchemaBase, total=False): type: Required[Literal['call']] - arguments_schema: Required[CoreSchema] + arguments_schema: Required[CoreSchemaBase] function: Required[Callable[..., Any]] - return_schema: CoreSchema + return_schema: CoreSchemaBase ref: str extra: Any serialization: SerSchema @@ -2318,7 +2318,7 @@ def recursive_reference_schema( class CustomErrorSchema(CoreSchemaBase, total=False): type: Required[Literal['custom-error']] - schema: Required[CoreSchema] + schema: Required[CoreSchemaBase] custom_error_type: Required[str] custom_error_message: str custom_error_context: Dict[str, Union[str, int, float]] @@ -2372,7 +2372,7 @@ def custom_error_schema( class JsonSchema(CoreSchemaBase, total=False): type: Required[Literal['json']] - schema: CoreSchema + schema: CoreSchemaBase ref: str extra: Any serialization: SerSchema