♻️ Replace Mashumaro with Probatio#658
Open
frenck wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the Fumis WiRCU API model layer from Mashumaro-based (de)serialization to Probatio-based validation/construction, and updates the CLI/tests to reflect the new model parsing and JSON output shape. It also standardizes “no error/alert” handling by introducing explicit enum members and bumps the minimum supported Python version to 3.12 to satisfy Probatio.
Changes:
- Replace Mashumaro strategies/aliases with Probatio schemas/coercers and make models plain frozen dataclasses, with
FumisInfo.from_dict()driving validation. - Change “no error/alert” from
Noneto explicitStoveError.NO_ERROR/StoveAlert.NO_ALERT, updating CLI and tests accordingly. - Update CLI
--jsonoutput and snapshots, and drop Python 3.11 across packaging metadata and CI matrices.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/fumis/models.py |
Reworks model parsing/validation to Probatio (coercers, aliases, extra-key dropping) and removes Mashumaro strategies. |
src/fumis/const.py |
Adds NO_ERROR/NO_ALERT members and makes from_code() return non-optional enums. |
src/fumis/cli/__init__.py |
Updates info --json emission and adapts error/alert display logic to the new sentinel enums. |
src/fumis/cli/tui.py |
Updates TUI rendering logic to treat NO_ERROR/NO_ALERT as the “empty” state. |
tests/test_fumis.py |
Updates unit tests to expect explicit NO_ERROR/NO_ALERT instead of None. |
tests/cli/__snapshots__/test_cli.ambr |
Refreshes CLI output snapshots to match new JSON/model shape and formatting. |
pyproject.toml |
Replaces Mashumaro dependency with Probatio, bumps requires-python to 3.12, and updates typing tool config. |
poetry.lock |
Updates lockfile for dependency changes (adds Probatio, removes Mashumaro) and Poetry generator version. |
.github/workflows/tests.yaml |
Drops Python 3.11 from the test matrix and updates default Python to 3.12. |
.github/workflows/typing.yaml |
Updates default Python to 3.12. |
.github/workflows/linting.yaml |
Updates default Python to 3.12. |
.github/workflows/release.yaml |
Updates default Python to 3.12. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Parse the Fumis WiRCU API into the model dataclasses with Probatio instead of Mashumaro. Models become plain frozen dataclasses that validate and construct through Probatio's SchemaMixin, dropping unmodeled keys, with field aliases on Key() and coercions on inline Coerce/FromEpoch/AsTimedelta/Maybe hints. Serialization for the `info --json` command moves to orjson, since Probatio validates but does not serialize. Also resolves error and alert codes to non-optional enums with explicit NO_ERROR/NO_ALERT members instead of None. Probatio requires Python 3.12, so 3.11 is dropped.
45da224 to
ceffaff
Compare
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.
Proposed Changes
Replaces Mashumaro with Probatio for turning the Fumis WiRCU API response into the model dataclasses.
The models are now plain frozen dataclasses.
FumisInfo.from_dict()validates and constructs the whole tree through Probatio'sSchemaMixinwithextra=REMOVE_EXTRA, so unmodeled keys (which vary by firmware) are dropped at every level. Field aliases move from Mashumaro'sfield_options(alias=...)toKey(alias=...), and the oldSerializationStrategyclasses become inline coercers:Coercefor the string-encoded numbers and versions,FromEpochfor timestamps,AsTimedeltafor the seconds counters, andMaybe(Coerce(...))for the-1-sentinel optionals. Probatio's numeric tower means plainfloatfields accept the integer values the device sends, so those fields carry no coercer at all.Probatio validates but does not serialize, so
fumis info --jsonnow serializes the model withorjsondirectly. The output is model shaped (snake_case keys, ISO timestamps,nullfields present) rather than the old aliased wire shape; thedumpcommand still emits the raw API payload untouched. The snapshot is updated to match.This also folds in the error handling cleanup that was in progress:
StoveError.from_code()andStoveAlert.from_code()now return a non-optional enum with explicitNO_ERROR/NO_ALERTmembers instead ofNone.Probatio requires Python 3.12, so this drops Python 3.11 (from
requires-python, the classifiers, and the CI matrix). Home Assistant is well past 3.11, so this should not hurt in practice.Related Issues