@@ -559,6 +559,15 @@ class HomogeneousSerializerFactory:
559
559
"""
560
560
561
561
class TextSerializer (Serializer ):
562
+ def __init__ (
563
+ self , model : Type ['pxml.BaseXmlModel' ], model_field : pd .fields .ModelField , ctx : Serializer .Context ,
564
+ ):
565
+ assert len (model_field .sub_fields ) == 1
566
+ if issubclass (model_field .type_ , pxml .BaseXmlModel ):
567
+ raise errors .ModelFieldError (
568
+ model .__name__ , model_field .name , "Inline list value should be of scalar type" ,
569
+ )
570
+
562
571
def serialize (
563
572
self , element : etree .Element , value : Any , * , encoder : XmlEncoder , skip_empty : bool = False ,
564
573
) -> Optional [etree .Element ]:
@@ -570,10 +579,7 @@ def serialize(
570
579
return element
571
580
572
581
def deserialize (self , element : etree .Element ) -> Optional [List [Any ]]:
573
- return [
574
- value
575
- for value in element .text .split ()
576
- ]
582
+ return [value for value in element .text .split ()]
577
583
578
584
class ElementSerializer (Serializer ):
579
585
def __init__ (
@@ -650,7 +656,7 @@ def build(
650
656
if field_location is Location .ELEMENT :
651
657
return cls .ElementSerializer (model , model_field , ctx )
652
658
elif field_location is Location .MISSING :
653
- return cls .TextSerializer ()
659
+ return cls .TextSerializer (model , model_field , ctx )
654
660
elif field_location is Location .ATTRIBUTE :
655
661
raise errors .ModelFieldError (
656
662
model .__name__ , model_field .name , "attributes of collection type are not supported" ,
0 commit comments