Add hybrid device type and mutable_variable_regex field#63
Merged
Conversation
mateuscardosodeveloper
approved these changes
Jul 8, 2026
mateuscardosodeveloper
left a comment
Contributor
There was a problem hiding this comment.
Approve
Additive type definitions plus a safe request-body change; the tests and the description hold up against the diff.
In this PR
Improvements
docs/source/Resources/Devices/Devices_Type.rst:343: theDeviceCreateInfoalias line still readsDeviceCreateInfoMutable or DeviceCreateInfoImmutableand there is noDeviceCreateInfoBasicHybridsection, so the Sphinx docs now lag the aliases this PR adds. Worth updating in the same pass that fixed the Immutable typo.src/tagoio_sdk/modules/Resources/Device_Type.py:61:str or Noneevaluates to plainstrat runtime; the same field usesOptional[str]inDeviceEditInfo(line 487). PreferOptional[str]here for a correct annotation and consistency within the PR.src/tagoio_sdk/modules/Resources/Device_Type.py:403: thechunk_periodandchunk_retentiondocstrings insideDeviceCreateInfoBasicHybridstill say "Required for Immutable devices" (also line 411). Saying they apply to the immutable side of a Hybrid device would avoid confusion.src/tagoio_sdk/modules/Resources/Device_Type.py:429: since this line was already touched, considerUnion[DeviceCreateInfoMutable, DeviceCreateInfoImmutable, DeviceCreateInfoHybrid]; theorchain evaluates to justDeviceCreateInfoMutableat runtime.
Praise
- The Immutable typo fix keeps the public alias
DeviceCreateInfoImmutablestable and the PR body explains why the literal change is a correction rather than a break. testEmptyDeviceDataWithRouteasserts the actual request body, and the omitted-params path stays safe:api_request.pydrops a null body before sending, so existing callers ofemptyDeviceDataare unaffected.
Risk (CIA)
Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low.
Confirmed. Type additions plus an optional request body whose None case is handled in api_request.py.
Outside this PR
Pre-existing
src/tagoio_sdk/modules/Resources/Device_Type.py:247: theX or Yannotation idiom appears throughout the file (description: str or None,Optional[str or None]at line 194) and produces wrong runtime types everywhere it is used. A file-wide sweep toOptional/Unionwould fix typing for every consumer; worth a separate issue.
Contributor
|
Release reminder: to cut the release that ships this change, bump |
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.
Summary
Adds the
hybriddevice storage type and itsmutable_variable_regexfield to the device create/edit/info types (and theDataStorageTypeliteral), matching backend tago-io/server#1644. Hybrid combines immutable telemetry (chunked, with retention) and editable mutable variables in one device, routed per-variable by the regex. Also corrects a long-standing typo in the immutable device type.Changes
DeviceCreateInfoBasicHybrid/DeviceCreateInfoHybridadded; extended theDeviceCreateInfoalias.mutable_variable_regexadded toDeviceEditInfoandDeviceInfo;"hybrid"added toDataStorageType.emptyDeviceData(deviceID, params=None)accepts{"route": "mutable" | "immutable"}(newDeviceEmptyParamsTypedDict) on hybrid devices to empty a single side; omitting it keeps the whole-device behavior for every type. Covered by a request-body test.mutable_variable_regexrejects match-everything / match-nothing patterns (the server rejects.*,^$, etc.; use a mutable or immutable device for those cases).type: Literal["imutable"]->Literal["immutable"], and renamed the classDeviceCreateInfoBasicImutable->DeviceCreateInfoBasicImmutable(with its alias reference and the Sphinx docs). The literal was wrong against the API (which usesimmutable), so this corrects broken typing rather than changing working behavior. The class is not part of the package__all__; the public aliasDeviceCreateInfoImmutableis unchanged.Test plan
uv run ruff check srccleanuv run ruff formatclean (changed files)uv run pytest tests/green (200 passed, incl. the new route-body test)Risk (CIA)
Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low
Additive type definitions plus a typo correction to a non-exported class; no runtime behavior change.
Related