1
1
import dataclasses as dc
2
2
import typing
3
- from typing import Any , Callable , Optional , Type , TypeVar , Union
3
+ from typing import Any , Callable , Optional , TypeVar , Union
4
4
5
5
import pydantic as pd
6
6
import pydantic_core as pdc
7
7
from pydantic ._internal ._model_construction import ModelMetaclass # noqa
8
8
from pydantic .root_model import _RootModelMetaclass as RootModelMetaclass # noqa
9
9
10
10
from . import config , model , utils
11
- from .element import XmlElementReader , XmlElementWriter
12
11
from .typedefs import EntityLocation
13
12
from .utils import NsMap
14
13
22
21
'xml_field_serializer' ,
23
22
'xml_field_validator' ,
24
23
'ComputedXmlEntityInfo' ,
25
- 'SerializerFunc' ,
26
- 'ValidatorFunc' ,
27
24
'XmlEntityInfo' ,
28
25
'XmlEntityInfoP' ,
29
26
'XmlFieldSerializer' ,
@@ -295,8 +292,7 @@ def computed_element(
295
292
return computed_entity (EntityLocation .ELEMENT , prop , path = tag , ns = ns , nsmap = nsmap , nillable = nillable , ** kwargs )
296
293
297
294
298
- ValidatorFunc = Callable [[Type ['model.BaseXmlModel' ], XmlElementReader , str ], Any ]
299
- ValidatorFuncT = TypeVar ('ValidatorFuncT' , bound = ValidatorFunc )
295
+ ValidatorFuncT = TypeVar ('ValidatorFuncT' , bound = 'model.SerializerFunc' )
300
296
301
297
302
298
def xml_field_validator (field : str , / , * fields : str ) -> Callable [[ValidatorFuncT ], ValidatorFuncT ]:
@@ -314,8 +310,7 @@ def wrapper(func: ValidatorFuncT) -> ValidatorFuncT:
314
310
return wrapper
315
311
316
312
317
- SerializerFunc = Callable [['model.BaseXmlModel' , XmlElementWriter , Any , str ], Any ]
318
- SerializerFuncT = TypeVar ('SerializerFuncT' , bound = SerializerFunc )
313
+ SerializerFuncT = TypeVar ('SerializerFuncT' , bound = 'model.SerializerFunc' )
319
314
320
315
321
316
def xml_field_serializer (field : str , / , * fields : str ) -> Callable [[SerializerFuncT ], SerializerFuncT ]:
@@ -335,9 +330,9 @@ def wrapper(func: SerializerFuncT) -> SerializerFuncT:
335
330
336
331
@dc .dataclass (frozen = True )
337
332
class XmlFieldValidator :
338
- func : ValidatorFunc
333
+ func : 'model. ValidatorFunc'
339
334
340
335
341
336
@dc .dataclass (frozen = True )
342
337
class XmlFieldSerializer :
343
- func : SerializerFunc
338
+ func : 'model. SerializerFunc'
0 commit comments