Skip to content

Conversation

dapper91
Copy link
Owner

Adds support for multiple field type annotations.

See the following example:

from typing import Annotated

import pydantic_xml as pxml
from annotated_types import Ge, Le


CompanyElement = pxml.element(ns='co', nsmap={'co': 'http://company-ns.com'})


class Company(pxml.BaseXmlModel, tag='Company'):
    founded: Annotated[int, Ge(ge=0), Le(le=2025), CompanyElement] = pxml.element(tag='foundYear')


xml = '''
<Company xmlns:co="http://company-ns.com">
    <co:foundYear>2020</co:foundYear>
</Company>
'''

print(Company.from_xml(xml))

Fixes the issue

@codecov-commenter
Copy link

codecov-commenter commented Jun 13, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 99.21875% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.31%. Comparing base (32e205c) to head (8d92470).

Files with missing lines Patch % Lines
pydantic_xml/fields.py 99.11% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #268      +/-   ##
==========================================
+ Coverage   92.15%   92.31%   +0.15%     
==========================================
  Files          29       30       +1     
  Lines        1695     1730      +35     
==========================================
+ Hits         1562     1597      +35     
  Misses        133      133              
Flag Coverage Δ
unittests 92.31% <99.21%> (+0.15%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dapper91 dapper91 merged commit d5afecd into dev Jun 13, 2025
6 checks passed
@dapper91 dapper91 mentioned this pull request Jun 13, 2025
Merged
@dapper91 dapper91 deleted the fix/field-info-merge branch June 13, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants