Skip to content

Drop pydantic v1 support#2084

Merged
rytilahti merged 4 commits into
masterfrom
drop-pydantic-v1
Jul 21, 2026
Merged

Drop pydantic v1 support#2084
rytilahti merged 4 commits into
masterfrom
drop-pydantic-v1

Conversation

@rytilahti

@rytilahti rytilahti commented Jul 21, 2026

Copy link
Copy Markdown
Owner
  • Drop pydantic v1 support; update all imports and API usage to pydantic v2.
  • Replace custom metaclass validators with the idiomatic Annotated[T, PlainValidator(fn)] pattern.
  • Use model_post_init instead of __init__ overrides.
  • Switch miot schema models to extra="allow" with warnings.warn on unknown fields for data from external sources.

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.
@rytilahti rytilahti added this to the 0.6.0 milestone Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.11828% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.37%. Comparing base (f07f5f3) to head (963eb68).

Files with missing lines Patch % Lines
miio/devtools/simulators/miiosimulator.py 0.00% 11 Missing ⚠️
miio/devtools/simulators/miotsimulator.py 0.00% 9 Missing ⚠️
miio/cloud.py 66.66% 2 Missing ⚠️
miio/miot_cloud.py 66.66% 2 Missing ⚠️
miio/miot_models.py 98.24% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

- 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.
@rytilahti
rytilahti merged commit 578ef14 into master Jul 21, 2026
13 of 14 checks passed
@rytilahti
rytilahti deleted the drop-pydantic-v1 branch July 21, 2026 22:55
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