Skip to content

Fix dataclass field ordering conflict when inheriting from parent with default fields#2664

Merged
koxudaxi merged 3 commits intomainfrom
fix/dataclass-inheritance-field-ordering
Dec 14, 2025
Merged

Fix dataclass field ordering conflict when inheriting from parent with default fields#2664
koxudaxi merged 3 commits intomainfrom
fix/dataclass-inheritance-field-ordering

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

Summary

  • Fix TypeError caused by dataclass field ordering when a child class inherits from a parent with default fields and adds new required fields
  • For Python 3.10+: Automatically add field(kw_only=True) to new required fields to avoid ordering conflict
  • For Python 3.9: Emit UserWarning since the issue cannot be automatically fixed

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.61%. Comparing base (747fed5) to head (35df298).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2664      +/-   ##
==========================================
- Coverage   99.66%   99.61%   -0.06%     
==========================================
  Files          76       76              
  Lines       10481    10538      +57     
  Branches     1261     1280      +19     
==========================================
+ Hits        10446    10497      +51     
- Misses         16       21       +5     
- Partials       19       20       +1     
Flag Coverage Δ
unittests 99.61% <100.00%> (-0.06%) ⬇️

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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Dec 14, 2025

CodSpeed Performance Report

Merging #2664 will not alter performance

Comparing fix/dataclass-inheritance-field-ordering (35df298) with main (f7ffbd0)

Summary

✅ 50 untouched
⏩ 3 skipped1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@koxudaxi koxudaxi marked this pull request as ready for review December 14, 2025 18:23
@koxudaxi koxudaxi merged commit 502f80a into main Dec 14, 2025
38 of 39 checks passed
@koxudaxi koxudaxi deleted the fix/dataclass-inheritance-field-ordering branch December 14, 2025 18:31
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.

1 participant