Repository navigation
fix: compare union defaults with dataclasses.MISSING (Python 3.15) - #984
Merged
marcosschroh merged 1 commit intoOct 17, 2026
Merged
marcosschroh merged 1 commit into
marcosschroh merged 1 commit into
Conversation
Python 3.15 removed dataclasses._MISSING_TYPE, so generating the schema of any union field failed with AttributeError. Closes #983
marcosschroh
approved these changes
Oct 17, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #984 +/- ##
==========================================
+ Coverage 98.72% 98.76% +0.04%
==========================================
Files 32 32
Lines 2271 2271
==========================================
+ Hits 2242 2243 +1
+ Misses 29 28 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #983
UnionField.generate_unions_typecheckedtype(self.default) is not dataclasses._MISSING_TYPE. Python 3.15 madedataclasses.MISSINGa PEP 661 sentinel and removed the private_MISSING_TYPEclass, so generating the schema of any union field raisedAttributeError(the issue's traceback).The check is now
self.default is not dataclasses.MISSING.MISSINGis a singleton on all supported versions, and the rest of the package (including theifright above this line) already compares with it this way.Tested with
poetry install --extras "pydantic faust faker"+pytest tests, in Docker:python:3.14python:3.15The issue's reproducer prints
{"type": "record", "name": "Class", "fields": [{"name": "field", "type": ["string", "long"]}]}on 3.15.The 35 remaining 3.15 failures are all in the faust tests and come from a dependency:
mode/utils/objects.pycallstyping._eval_type()without thetype_paramsargument that 3.15 now requires. Nothing in this repo is involved, so I left those alone and didn't add 3.15 to the CI matrix.dataclasses._MISSING_TYPEis still used in three return annotations (fields.pylines 200, 282, 571). Those don't run at runtime on 3.14+ (annotations are lazy), and typeshed still declares the class, so I didn't change them here.