11import dataclasses as dc
22import typing
3- from typing import Any , Callable , Optional , Type , TypeVar , Union
3+ from typing import Any , Callable , Optional , TypeVar , Union
44
55import pydantic as pd
66import pydantic_core as pdc
77from pydantic ._internal ._model_construction import ModelMetaclass # noqa
88from pydantic .root_model import _RootModelMetaclass as RootModelMetaclass # noqa
99
1010from . import config , model , utils
11- from .element import XmlElementReader , XmlElementWriter
1211from .typedefs import EntityLocation
1312from .utils import NsMap
1413
2221 'xml_field_serializer' ,
2322 'xml_field_validator' ,
2423 'ComputedXmlEntityInfo' ,
25- 'SerializerFunc' ,
26- 'ValidatorFunc' ,
2724 'XmlEntityInfo' ,
2825 'XmlEntityInfoP' ,
2926 'XmlFieldSerializer' ,
@@ -295,8 +292,7 @@ def computed_element(
295292 return computed_entity (EntityLocation .ELEMENT , prop , path = tag , ns = ns , nsmap = nsmap , nillable = nillable , ** kwargs )
296293
297294
298- ValidatorFunc = Callable [[Type ['model.BaseXmlModel' ], XmlElementReader , str ], Any ]
299- ValidatorFuncT = TypeVar ('ValidatorFuncT' , bound = ValidatorFunc )
295+ ValidatorFuncT = TypeVar ('ValidatorFuncT' , bound = 'model.SerializerFunc' )
300296
301297
302298def xml_field_validator (field : str , / , * fields : str ) -> Callable [[ValidatorFuncT ], ValidatorFuncT ]:
@@ -314,8 +310,7 @@ def wrapper(func: ValidatorFuncT) -> ValidatorFuncT:
314310 return wrapper
315311
316312
317- SerializerFunc = Callable [['model.BaseXmlModel' , XmlElementWriter , Any , str ], Any ]
318- SerializerFuncT = TypeVar ('SerializerFuncT' , bound = SerializerFunc )
313+ SerializerFuncT = TypeVar ('SerializerFuncT' , bound = 'model.SerializerFunc' )
319314
320315
321316def xml_field_serializer (field : str , / , * fields : str ) -> Callable [[SerializerFuncT ], SerializerFuncT ]:
@@ -335,9 +330,9 @@ def wrapper(func: SerializerFuncT) -> SerializerFuncT:
335330
336331@dc .dataclass (frozen = True )
337332class XmlFieldValidator :
338- func : ValidatorFunc
333+ func : 'model. ValidatorFunc'
339334
340335
341336@dc .dataclass (frozen = True )
342337class XmlFieldSerializer :
343- func : SerializerFunc
338+ func : 'model. SerializerFunc'
0 commit comments