33from typing import TYPE_CHECKING , Any , Literal , cast
44
55from issubclass import issubclass as lenient_issubclass
6- from pydantic import BaseModel , Field
6+ from pydantic import AliasChoices , AliasPath , BaseModel , Field
77from pydantic ._internal ._decorators import PydanticDescriptorProxy , unwrap_wrapped_function
8+ from pydantic .config import JsonDict
89from pydantic .fields import FieldInfo
910
1011from cadwyn ._utils import Sentinel , fully_unwrap_decorator
1920PossibleFieldAttributes = Literal [
2021 "default" ,
2122 "default_factory" ,
22- "alias" ,
23+ "alias_priority" ,
24+ "validation_alias" ,
25+ "serialization_alias" ,
2326 "title" ,
27+ "field_title_generator" ,
2428 "description" ,
29+ "examples" ,
2530 "exclude" ,
2631 "const" ,
32+ "deprecated" ,
33+ "frozen" ,
34+ "validate_default" ,
35+ "repr" ,
36+ "init" ,
37+ "init_var" ,
38+ "kw_only" ,
39+ "fail_fast" ,
2740 "gt" ,
2841 "ge" ,
2942 "lt" ,
3043 "le" ,
31- "deprecated" ,
32- "fail_fast" ,
3344 "strict" ,
45+ "coerce_numbers_to_str" ,
3446 "multiple_of" ,
3547 "allow_inf_nan" ,
3648 "max_digits" ,
3749 "decimal_places" ,
3850 "min_length" ,
3951 "max_length" ,
52+ "union_mode" ,
4053 "allow_mutation" ,
4154 "pattern" ,
4255 "discriminator" ,
43- "repr" ,
4456]
4557
4658
59+ # TODO: Add json_schema_extra as a breaking change in a major version
4760@dataclass (slots = True )
4861class FieldChanges :
4962 default : Any
5063 default_factory : Any
51- alias : str
52- title : str
64+ alias_priority : int | None
65+ validation_alias : str | AliasPath | AliasChoices | None
66+ serialization_alias : str | None
67+ title : str | None
68+ field_title_generator : Callable [[str , FieldInfo ], str ] | None
5369 description : str
70+ examples : list [Any ] | None
5471 exclude : "AbstractSetIntStr | MappingIntStrAny | Any"
5572 const : bool
5673 deprecated : bool
74+ frozen : bool | None
75+ validate_default : bool | None
76+ repr : bool
77+ init : bool | None
78+ init_var : bool | None
79+ kw_only : bool | None
5780 fail_fast : bool
5881 gt : float
5982 ge : float
6083 lt : float
6184 le : float
6285 strict : bool
86+ coerce_numbers_to_str : bool | None
6387 multiple_of : float
6488 allow_inf_nan : bool
6589 max_digits : int
6690 decimal_places : int
6791 min_length : int
6892 max_length : int
93+ union_mode : Literal ["smart" , "left_to_right" ]
6994 allow_mutation : bool
7095 pattern : str
7196 discriminator : str
72- repr : bool
7397
7498
7599@dataclass (slots = True )
@@ -114,28 +138,39 @@ def had(
114138 type : Any = Sentinel ,
115139 default : Any = Sentinel ,
116140 default_factory : Callable = Sentinel ,
117- alias : str = Sentinel ,
141+ alias_priority : int = Sentinel ,
142+ validation_alias : str = Sentinel ,
143+ serialization_alias : str = Sentinel ,
118144 title : str = Sentinel ,
145+ field_title_generator : Callable [[str , FieldInfo ], str ] = Sentinel ,
119146 description : str = Sentinel ,
147+ examples : list [Any ] = Sentinel ,
120148 exclude : "AbstractSetIntStr | MappingIntStrAny | Any" = Sentinel ,
121149 const : bool = Sentinel ,
150+ deprecated : bool = Sentinel ,
151+ frozen : bool = Sentinel ,
152+ validate_default : bool = Sentinel ,
153+ repr : bool = Sentinel ,
154+ init : bool = Sentinel ,
155+ init_var : bool = Sentinel ,
156+ kw_only : bool = Sentinel ,
157+ fail_fast : bool = Sentinel ,
122158 gt : float = Sentinel ,
123159 ge : float = Sentinel ,
124160 lt : float = Sentinel ,
125161 le : float = Sentinel ,
126162 strict : bool = Sentinel ,
127- deprecated : bool = Sentinel ,
163+ coerce_numbers_to_str : bool = Sentinel ,
128164 multiple_of : float = Sentinel ,
129165 allow_inf_nan : bool = Sentinel ,
130166 max_digits : int = Sentinel ,
131167 decimal_places : int = Sentinel ,
132168 min_length : int = Sentinel ,
133169 max_length : int = Sentinel ,
170+ union_mode : Literal ["smart" , "left_to_right" ] = Sentinel ,
134171 allow_mutation : bool = Sentinel ,
135172 pattern : str = Sentinel ,
136173 discriminator : str = Sentinel ,
137- repr : bool = Sentinel ,
138- fail_fast : bool = Sentinel ,
139174 ) -> FieldHadInstruction :
140175 return FieldHadInstruction (
141176 schema = self .schema ,
@@ -145,28 +180,39 @@ def had(
145180 field_changes = FieldChanges (
146181 default = default ,
147182 default_factory = default_factory ,
148- alias = alias ,
183+ alias_priority = alias_priority ,
184+ validation_alias = validation_alias ,
185+ serialization_alias = serialization_alias ,
149186 title = title ,
187+ field_title_generator = field_title_generator ,
150188 description = description ,
189+ examples = examples ,
151190 exclude = exclude ,
152191 const = const ,
192+ deprecated = deprecated ,
193+ frozen = frozen ,
194+ validate_default = validate_default ,
195+ repr = repr ,
196+ init = init ,
197+ init_var = init_var ,
198+ kw_only = kw_only ,
199+ fail_fast = fail_fast ,
153200 gt = gt ,
154201 ge = ge ,
155202 lt = lt ,
156203 le = le ,
157- deprecated = deprecated ,
158204 strict = strict ,
205+ coerce_numbers_to_str = coerce_numbers_to_str ,
159206 multiple_of = multiple_of ,
160207 allow_inf_nan = allow_inf_nan ,
161208 max_digits = max_digits ,
162209 decimal_places = decimal_places ,
163210 min_length = min_length ,
164211 max_length = max_length ,
212+ union_mode = union_mode ,
165213 allow_mutation = allow_mutation ,
166214 pattern = pattern ,
167215 discriminator = discriminator ,
168- repr = repr ,
169- fail_fast = fail_fast ,
170216 ),
171217 )
172218
0 commit comments