Skip to content

refactor: Migrate to typing.Self and remove __future__ annotations.#798

Merged
allenporter merged 3 commits intoPython-roborock:mainfrom
allenporter:chore-modernize-types
Mar 23, 2026
Merged

refactor: Migrate to typing.Self and remove __future__ annotations.#798
allenporter merged 3 commits intoPython-roborock:mainfrom
allenporter:chore-modernize-types

Conversation

@allenporter
Copy link
Contributor

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.

Copilot AI review requested due to automatic review settings March 22, 2026 18:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 annotations from a set of modules to avoid stringified annotations at runtime.
  • Introduced typing.Self and updated a few method annotations to use it (notably Enum _missing_ and DeviceProp.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.

@allenporter allenporter force-pushed the chore-modernize-types branch from bfd3c1e to ec260fc Compare March 22, 2026 19:49
@allenporter allenporter force-pushed the chore-modernize-types branch from ec260fc to ba2fdf4 Compare March 22, 2026 20:08
@allenporter allenporter merged commit d762649 into Python-roborock:main Mar 23, 2026
6 of 7 checks passed
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.

3 participants