Drop pydantic v1 support#2084
Merged
Merged
Conversation
Remove the pydantic v1 compatibility shims and migrate all code to the v2 API. Fix implicit default=None on nullable aliased fields that v2 now requires explicitly. Add MiotPythonType TypeAlias shared between miot_models and the miio simulator.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2084 +/- ##
==========================================
+ Coverage 84.27% 84.37% +0.09%
==========================================
Files 201 201
Lines 20386 20365 -21
Branches 1073 1076 +3
==========================================
+ Hits 17181 17182 +1
+ Misses 3014 2993 -21
+ Partials 191 190 -1 ☔ View full report in Codecov by Harness. |
- Replace format type metaclasses with the pydantic v2 Annotated pattern. - Use model_post_init instead of __init__ for post-validation setup. - Switch miot schema models to extra="allow" since data comes from external sources. - Warn on unknown fields via warnings.warn so they surface to users for reporting.
- Verify unknown fields produce a warning for all miot model classes. - Verify URN validator handles non-string input and rejects strings without colons. - Verify _create_range_descriptor raises when format is None.
- Add from __future__ import annotations to drop quoted forward references. - Raise TypeError in validate_from_str for unexpected input types instead of silently passing them through; dicts are still allowed for dict-based construction.
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.
Annotated[T, PlainValidator(fn)]pattern.model_post_initinstead of__init__overrides.extra="allow"withwarnings.warnon unknown fields for data from external sources.