According to the docs, the order of the types in the union is respected. But when using str, it seems that it always wins:
from pydantic_xml import BaseXmlModel, attr
class Model(BaseXmlModel):
x: float | bool = attr()
y: bool | float = attr()
z: str | float = attr()
w: float | str = attr()
Model.from_xml("<Model x='1' y='1' z='1' w='1' />")
Output:
Model(x=1.0, y=True, z='1', w='1')
Expected:
Model(x=1.0, y=True, z='1', w=1.0)