dapper91 / pydantic-xml

python xml for humans
https://pydantic-xml.readthedocs.io
The Unlicense
155 stars 16 forks source link

piped union typehint support added #58

Closed dapper91 closed 1 year ago

dapper91 commented 1 year ago

Starting from python 3.10 it is possible to describe union types using pipe (X | Y). See https://peps.python.org/pep-0604/.

Therefore this syntax is correct starting from python 3.10 and should be supported by the library:

class Model(BaseXmlModel):
    text: int | float | str

Fixes the issue https://github.com/dapper91/pydantic-xml/issues/56.

codecov-commenter commented 1 year ago

Codecov Report

Merging #58 (0056d88) into dev (4b5779f) will increase coverage by 0.03%. The diff coverage is 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##              dev      #58      +/-   ##
==========================================
+ Coverage   93.70%   93.73%   +0.03%     
==========================================
  Files          22       22              
  Lines        1032     1038       +6     
==========================================
+ Hits          967      973       +6     
  Misses         65       65              
Flag Coverage Δ
unittests 93.73% <100.00%> (+0.03%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pydantic_xml/__init__.py 100.00% <100.00%> (ø)
pydantic_xml/model.py 100.00% <100.00%> (ø)
pydantic_xml/serializers/serializer.py 97.02% <100.00%> (+0.15%) :arrow_up: