Skip to content

Conversation

@NGHades
Copy link

@NGHades NGHades commented Aug 11, 2025

Problem

This PR addresses issue #2110, which we (@kevJ711 and @KViruz2750) identified while working with Annotated types in conjunction with pa.Field(...).

Description

When defining schema models using Annotated along with pa.Field(...), metadata such as description, unique, and title was not being correctly propagated into the resulting DataFrameModel.

Solution

We introduced a more rigorous check for parsing Annotated types to ensure that any AnnotationInfo attached to a type is correctly handled and its metadata extracted. This change allows the model to capture and utilize metadata as expected.

Additionally, we observed that certain built-in types (str, int, float, bool) do not support parameterization. To prevent issues when handling these types, we added a check that safely returns an empty metadata dictionary for them.

@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.69%. Comparing base (812b2a8) to head (af4c344).
⚠️ Report is 376 commits behind head on main.

Files with missing lines Patch % Lines
pandera/api/dataframe/model.py 80.76% 5 Missing ⚠️
pandera/api/pandas/model.py 66.66% 2 Missing ⚠️
pandera/api/pyspark/model.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2111       +/-   ##
===========================================
- Coverage   94.28%   82.69%   -11.59%     
===========================================
  Files          91      135       +44     
  Lines        7013    10589     +3576     
===========================================
+ Hits         6612     8757     +2145     
- Misses        401     1832     +1431     

☔ 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.

@cosmicBboy
Copy link
Collaborator

thanks for the contribution @NGHades ! looks like there are a few failing tests. you can repro this locally using nox, see here: https://pandera.readthedocs.io/en/stable/CONTRIBUTING.html#run-a-specific-test-suite-locally

Comment on lines +173 to +174
if field_info_list:
existing_field = field_info_list[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to provide an inline comment here, why you're retrieving the first item

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.

3 participants