diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abc45c38..f67cfa10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: - python-version: "3.11" + python-version: "3.12" - uses: pre-commit/action@v3.0.1 test: @@ -35,7 +35,7 @@ jobs: fail-fast: false matrix: python-version: - - "3.11" + - "3.12" - "3.14" runs-on: ubuntu-latest steps: @@ -59,7 +59,7 @@ jobs: - name: Set up uv uses: astral-sh/setup-uv@v7 with: - python-version: "3.11" + python-version: "3.12" activate-environment: true - name: Build package run: uv build diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 18b2b295..3f211c51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: args: - --fix - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.7.1 + rev: v1.18.2 hooks: - id: mypy exclude: cli.py diff --git a/mypy.ini b/mypy.ini index f6f59369..82649610 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,4 +1,5 @@ [mypy] +python_version = 3.12 check_untyped_defs = True [mypy-construct] diff --git a/pyproject.toml b/pyproject.toml index 9711187c..12b77bcd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "python-roborock" version = "3.3.2" description = "A package to control Roborock vacuums." authors = [{ name = "humbertogontijo", email = "humbertogontijo@users.noreply.github.com" }, {name="Lash-L"}, {name="allenporter"}] -requires-python = ">=3.11, <4" +requires-python = ">=3.12, <4" readme = "README.md" license = "GPL-3.0-only" keywords = [ diff --git a/roborock/cloud_api.py b/roborock/cloud_api.py index ad184c24..f85aafe1 100644 --- a/roborock/cloud_api.py +++ b/roborock/cloud_api.py @@ -118,7 +118,7 @@ def _mqtt_on_message(self, *args, **kwargs): client, __, msg = args try: messages = self._decoder(msg.payload) - super().on_message_received(messages) + self.on_message_received(messages) except Exception as ex: self._logger.exception(ex) diff --git a/roborock/data/containers.py b/roborock/data/containers.py index 8852b849..d2faac70 100644 --- a/roborock/data/containers.py +++ b/roborock/data/containers.py @@ -77,7 +77,7 @@ def from_dict(cls, data: dict[str, Any]): """Create an instance of the class from a dictionary.""" if not isinstance(data, dict): return None - field_types = {field.name: field.type for field in dataclasses.fields(cls)} + field_types: dict[str, type] = {field.name: field.type for field in dataclasses.fields(cls)} result: dict[str, Any] = {} for orig_key, value in data.items(): key = _decamelize(orig_key) diff --git a/roborock/devices/traits/v1/__init__.py b/roborock/devices/traits/v1/__init__.py index a5735511..af0278ed 100644 --- a/roborock/devices/traits/v1/__init__.py +++ b/roborock/devices/traits/v1/__init__.py @@ -32,7 +32,7 @@ import logging from dataclasses import dataclass, field, fields -from typing import Any, get_args +from typing import Any, cast, get_args from roborock.data.containers import HomeData, HomeDataProduct, RoborockBase from roborock.data.v1.v1_code_mappings import RoborockDockTypeCode @@ -152,7 +152,7 @@ def __init__( if (union_args := get_args(item.type)) is None or len(union_args) > 0: continue _LOGGER.debug("Trait '%s' is supported, initializing", item.name) - trait = item.type() + trait = cast(type, item.type)() setattr(self, item.name, trait) # This is a hack to allow setting the rpc_channel on all traits. This is # used so we can preserve the dataclass behavior when the values in the diff --git a/roborock/protocol.py b/roborock/protocol.py index 9d6cbca5..42d984e5 100644 --- a/roborock/protocol.py +++ b/roborock/protocol.py @@ -329,9 +329,10 @@ def _parse(self, stream, context, path): hash1 = self.checksumfield.parse_stream(stream, **context) hash2 = self.hashfunc(self.bytesfunc(context)) if hash1 != hash2: + hash1_out = hash1 if not isinstance(hash1, bytestringtype) else binascii.hexlify(hash1) + hash2_out = hash2 if not isinstance(hash2, bytestringtype) else binascii.hexlify(hash2) raise ChecksumError( - f"wrong checksum, read {hash1 if not isinstance(hash1, bytestringtype) else binascii.hexlify(hash1)}, " - f"computed {hash2 if not isinstance(hash2, bytestringtype) else binascii.hexlify(hash2)}", + f"wrong checksum, read {hash1_out!r}, computed {hash2_out!r}", path=path, ) return hash1 diff --git a/uv.lock b/uv.lock index 0c158aba..3f9087e4 100644 --- a/uv.lock +++ b/uv.lock @@ -1,6 +1,6 @@ version = 1 revision = 3 -requires-python = ">=3.11, <4" +requires-python = ">=3.12, <4" [[package]] name = "aiohappyeyeballs"