Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make FieldInfo a protocol #949

Merged
merged 4 commits into from
Feb 19, 2024
Merged

Conversation

tlambert03
Copy link
Contributor

📒 Description

This makes a modification to #848 to make the dataclass.compat.FieldInfo type a bit more accurate. In #848, the return type was changed to a NamedTuple, but that named tuple wasn't actually used anywhere, instead, a regular dataclasses.Field is returned (as it was before) but it's just cast to the FieldInfo to satisfy type checkers. This means that all downstream users now get a typing error unless they also import your FieldInfo object and use a cast as well, even though they technically are returning the same Field object that you are returning internally.

🔗 What I've Done

I used a Protocol that matches the subset of dataclasses.Field that you are using, rather than the combination of NamedTuple and yield from cast(List[FieldInfo], fields(obj))

💬 Comments

A place to write any comments to the reviewer.

🛫 Checklist

Copy link

codecov bot commented Feb 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cf3aa92) 99.97% compared to head (3b308d4) 99.97%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #949   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files         109      109           
  Lines        8762     8763    +1     
  Branches     2075     2075           
=======================================
+ Hits         8760     8761    +1     
  Misses          1        1           
  Partials        1        1           

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

Copy link

sonarcloud bot commented Feb 18, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@tefra tefra merged commit b4b6a58 into tefra:main Feb 19, 2024
13 of 15 checks passed
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.

None yet

2 participants