refactor: Migrate to typing.Self and remove __future__ annotations.#798
Merged
allenporter merged 3 commits intoPython-roborock:mainfrom Mar 23, 2026
Merged
Conversation
Lash-L
reviewed
Mar 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors type annotations across the library to remove from __future__ import annotations (so annotations remain real runtime types for reflection) and migrates a few self-referential annotations to typing.Self, helping unblock upcoming feature work (e.g., #746).
Changes:
- Removed
from __future__ import annotationsfrom a set of modules to avoid stringified annotations at runtime. - Introduced
typing.Selfand updated a few method annotations to use it (notably Enum_missing_andDeviceProp.update). - Adjusted one self-referential annotation to a quoted forward reference to keep runtime import behavior working without
__future__.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| roborock/web_api.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/util.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/roborock_typing.py | Imports/uses typing.Self for DeviceProp.update. |
| roborock/roborock_message.py | Imports/uses typing.Self for Enum _missing_ typing. |
| roborock/protocol.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/exceptions.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/diagnostics.py | Drops __future__ annotations; introduces a quoted forward reference for a self-type. |
| roborock/devices/traits/v1/network_info.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/devices/traits/b01/q7/clean_summary.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/devices/rpc/b01_q10_channel.py | Drops __future__ annotations to preserve runtime type objects. |
| roborock/data/v1/v1_code_mappings.py | Imports/uses typing.Self for Enum _missing_ typing. |
| roborock/data/code_mappings.py | Updates RoborockEnum classmethod annotations to use Self. |
| roborock/broadcast_protocol.py | Drops __future__ annotations to preserve runtime type objects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bfd3c1e to
ec260fc
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ec260fc to
ba2fdf4
Compare
Lash-L
approved these changes
Mar 22, 2026
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.
This removes the use of future annotations which are converting all the types to string, making it harder to do type reflection.
This is needed to simplify #746
One instance of annotations is left that would otherwise cause a circular import and needs to be fixed.