fix(dataframe-model): preserve Annotated Field metadata in DataFrameModel#2302
Closed
RedZapdos123 wants to merge 3 commits into
Closed
fix(dataframe-model): preserve Annotated Field metadata in DataFrameModel#2302RedZapdos123 wants to merge 3 commits into
RedZapdos123 wants to merge 3 commits into
Conversation
Extract FieldInfo from typing.Annotated metadata when a DataFrameModel field omits explicit assignment so field properties (description/title/unique/etc.) are preserved. Also ignore FieldInfo entries when deriving dtype kwargs from Annotated metadata, keeping dtype parameter parsing correct for extension dtypes. Add pandas regression tests for omitted-field metadata propagation and mixed Annotated dtype + Field metadata. Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2302 +/- ##
==========================================
+ Coverage 82.64% 82.67% +0.02%
==========================================
Files 179 179
Lines 15163 15177 +14
==========================================
+ Hits 12532 12548 +16
+ Misses 2631 2629 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add a focused regression test that exercises the get_dtype_kwargs inspect.signature exception fallback path to improve patch coverage for issue unionai-oss#2110 changes. Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
Replace the Annotated[type(None)] fallback coverage test with a monkeypatched inspect.signature stub so the get_dtype_kwargs exception branch is exercised consistently across Python versions. Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
Contributor
Author
|
Closed this as the issue was fixed already. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Issue #2110 reported that metadata provided through typing.Annotated[..., pa.Field(...)] could be dropped when a DataFrameModel field omitted explicit assignment, because init_subclass created a default empty Field() instead of reusing annotation metadata.
This PR updates shared DataFrameModel annotation handling to preserve FieldInfo from Annotated metadata when initializing omitted fields. It also updates dtype-kwargs extraction to ignore FieldInfo metadata entries, so mixed Annotated[pd.DatetimeTZDtype, ..., pa.Field(...)] annotations continue to parse dtype args correctly.
It adds regression tests that cover:
Closes #2110.
Checklist:
The validation screenshots of the tests run, locally on WSL: