From ca2040ce08227834824eb3b1a6ee6c3c46055379 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 08:31:47 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- proto/hatch_build.py | 1 - src/ota_metadata/legacy/parser.py | 1 - src/ota_metadata/utils/cert_store.py | 1 - src/ota_proxy/cache_streaming.py | 1 - src/ota_proxy/db.py | 2 -- src/ota_proxy/external_cache.py | 1 - src/ota_proxy/lru_cache_helper.py | 1 - src/ota_proxy/ota_cache.py | 4 +++- src/ota_proxy/server_app.py | 2 +- src/otaclient/_logging.py | 1 - src/otaclient/_otaproxy_ctx.py | 1 - src/otaclient/_status_monitor.py | 2 -- src/otaclient/_types.py | 1 - src/otaclient/_utils.py | 1 - src/otaclient/boot_control/_firmware_package.py | 1 - src/otaclient/boot_control/_grub.py | 1 - src/otaclient/boot_control/_jetson_cboot.py | 1 - src/otaclient/boot_control/_jetson_common.py | 1 - src/otaclient/boot_control/_jetson_uefi.py | 1 - src/otaclient/boot_control/_ota_status_control.py | 1 - src/otaclient/boot_control/_rpi_boot.py | 1 - src/otaclient/boot_control/_slot_mnt_helper.py | 1 - src/otaclient/configs/__init__.py | 1 - src/otaclient/configs/_cfg_configurable.py | 1 - src/otaclient/configs/_cfg_consts.py | 2 -- src/otaclient/configs/_ecu_info.py | 1 - src/otaclient/configs/_proxy_info.py | 1 - src/otaclient/configs/cfg.py | 1 - src/otaclient/create_standby/common.py | 1 - src/otaclient/create_standby/interface.py | 1 - src/otaclient/errors.py | 1 - src/otaclient/grpc/api_v2/ecu_status.py | 2 -- src/otaclient/grpc/api_v2/ecu_tracker.py | 2 -- src/otaclient/grpc/api_v2/main.py | 1 - src/otaclient/grpc/api_v2/servicer.py | 1 - src/otaclient/grpc/api_v2/types.py | 1 - src/otaclient/main.py | 1 - src/otaclient/ota_core.py | 3 --- src/otaclient_api/v2/api_caller.py | 1 - src/otaclient_api/v2/types.py | 1 - src/otaclient_common/__init__.py | 1 - src/otaclient_common/_io.py | 1 - src/otaclient_common/cmdhelper.py | 1 - src/otaclient_common/common.py | 1 - src/otaclient_common/downloader.py | 2 -- src/otaclient_common/proto_streamer.py | 1 - src/otaclient_common/retry_task_map.py | 2 -- src/otaclient_common/shm_status.py | 3 --- src/otaclient_common/typing.py | 1 - tests/test_ota_proxy/test_cache_streaming.py | 4 +++- tests/test_ota_proxy/test_ota_cache.py | 1 - .../test_otaclient/test_boot_control/test_jetson_common.py | 4 ---- tests/test_otaclient/test_boot_control/test_jetson_uefi.py | 2 -- tests/test_otaclient/test_create_standby.py | 1 - .../test_grpc/test_api_v2/test_ecu_status.py | 4 +++- tests/test_otaclient/test_status_monitor.py | 2 -- tests/test_otaclient/test_utils.py | 1 - tests/test_otaclient_api/test_v2/test_types.py | 7 +++++-- tests/test_otaclient_common/test_downloader.py | 3 --- tests/test_otaclient_common/test_io.py | 1 - tests/test_otaclient_common/test_retry_task_map.py | 1 - tools/local_ota/api_v2.py | 1 - tools/offline_ota_image_builder/__main__.py | 1 - tools/offline_ota_image_builder/manifest.py | 1 - tools/offline_ota_image_builder/utils.py | 1 - 65 files changed, 15 insertions(+), 84 deletions(-) diff --git a/proto/hatch_build.py b/proto/hatch_build.py index ad8130733..b36ec09ee 100644 --- a/proto/hatch_build.py +++ b/proto/hatch_build.py @@ -13,7 +13,6 @@ # limitations under the License. """Dynamically generate protobuf python code.""" - from __future__ import annotations import os diff --git a/src/ota_metadata/legacy/parser.py b/src/ota_metadata/legacy/parser.py index 36f5669aa..165908f14 100644 --- a/src/ota_metadata/legacy/parser.py +++ b/src/ota_metadata/legacy/parser.py @@ -36,7 +36,6 @@ """ - from __future__ import annotations import atexit diff --git a/src/ota_metadata/utils/cert_store.py b/src/ota_metadata/utils/cert_store.py index 6c6e7579d..729ae8af1 100644 --- a/src/ota_metadata/utils/cert_store.py +++ b/src/ota_metadata/utils/cert_store.py @@ -13,7 +13,6 @@ # limitations under the License. """Implementation of otaclient CA cert chain store.""" - from __future__ import annotations import logging diff --git a/src/ota_proxy/cache_streaming.py b/src/ota_proxy/cache_streaming.py index 17e14b02f..97fc425d5 100644 --- a/src/ota_proxy/cache_streaming.py +++ b/src/ota_proxy/cache_streaming.py @@ -13,7 +13,6 @@ # limitations under the License. """Implementation of cache streaming.""" - from __future__ import annotations import asyncio diff --git a/src/ota_proxy/db.py b/src/ota_proxy/db.py index 9dc8af168..fd56c689e 100644 --- a/src/ota_proxy/db.py +++ b/src/ota_proxy/db.py @@ -116,7 +116,6 @@ def export_headers_to_client(self) -> CIMultiDict[str]: class CacheMetaORM(ORMBase[CacheMeta]): - def cachemeta_create_indexes(self) -> None: _indexes = { "bucket_idx_index": CacheMeta.table_create_index_stmt( @@ -138,7 +137,6 @@ def cachemeta_create_indexes(self) -> None: class AsyncCacheMetaORM(AsyncORMBase[CacheMeta]): - async def rotate_cache( self, bucket_idx: int, num: int ) -> Optional[list[CacheMeta]]: diff --git a/src/ota_proxy/external_cache.py b/src/ota_proxy/external_cache.py index 87edf60b7..fd22f57aa 100644 --- a/src/ota_proxy/external_cache.py +++ b/src/ota_proxy/external_cache.py @@ -13,7 +13,6 @@ # limitations under the License. """Implementation of mounting/umounting external cache.""" - from __future__ import annotations import logging diff --git a/src/ota_proxy/lru_cache_helper.py b/src/ota_proxy/lru_cache_helper.py index 8772e14d5..38972122e 100644 --- a/src/ota_proxy/lru_cache_helper.py +++ b/src/ota_proxy/lru_cache_helper.py @@ -13,7 +13,6 @@ # limitations under the License. """Implementation of OTA cache control.""" - from __future__ import annotations import bisect diff --git a/src/ota_proxy/ota_cache.py b/src/ota_proxy/ota_cache.py index 3c8fbacf0..27cef1154 100644 --- a/src/ota_proxy/ota_cache.py +++ b/src/ota_proxy/ota_cache.py @@ -400,7 +400,9 @@ async def _do_request() -> AsyncIterator[bytes]: yield data # open remote connection - resp_headers: CIMultiDictProxy[str] = await (_remote_fd := _do_request()).__anext__() # type: ignore + resp_headers: CIMultiDictProxy[str] = await ( + _remote_fd := _do_request() + ).__anext__() # type: ignore return _remote_fd, resp_headers async def _retrieve_file_by_cache_lookup( diff --git a/src/ota_proxy/server_app.py b/src/ota_proxy/server_app.py index bd1999a00..9714ae132 100644 --- a/src/ota_proxy/server_app.py +++ b/src/ota_proxy/server_app.py @@ -92,7 +92,7 @@ def parse_raw_headers(raw_headers: List[Tuple[bytes, bytes]]) -> Dict[str, str]: def encode_headers( - headers: Union[CIMultiDict[str], CIMultiDictProxy[str]] + headers: Union[CIMultiDict[str], CIMultiDictProxy[str]], ) -> List[Tuple[bytes, bytes]]: """Encode headers dict to list of bytes tuples for sending back to client. diff --git a/src/otaclient/_logging.py b/src/otaclient/_logging.py index 687d17c33..bc51dd6b9 100644 --- a/src/otaclient/_logging.py +++ b/src/otaclient/_logging.py @@ -13,7 +13,6 @@ # limitations under the License. """Configure the logging for otaclient.""" - from __future__ import annotations import atexit diff --git a/src/otaclient/_otaproxy_ctx.py b/src/otaclient/_otaproxy_ctx.py index e08a50638..53873e137 100644 --- a/src/otaclient/_otaproxy_ctx.py +++ b/src/otaclient/_otaproxy_ctx.py @@ -16,7 +16,6 @@ The API exposed by this module is meant to be controlled by otaproxy managing thread only. """ - from __future__ import annotations import asyncio diff --git a/src/otaclient/_status_monitor.py b/src/otaclient/_status_monitor.py index 9db09cfe0..a3f3a7e2e 100644 --- a/src/otaclient/_status_monitor.py +++ b/src/otaclient/_status_monitor.py @@ -13,7 +13,6 @@ # limitations under the License. """The implementation of tracking otaclient operation status.""" - from __future__ import annotations import atexit @@ -72,7 +71,6 @@ class SetOTAClientMetaReport: @dataclass class UpdateProgressReport: - class Type(Enum): # NOTE: PREPARE_LOCAL, DOWNLOAD_REMOTE and APPLY_DELTA are together # counted as diff --git a/src/otaclient/_types.py b/src/otaclient/_types.py index 92981290d..0d3b04ed8 100644 --- a/src/otaclient/_types.py +++ b/src/otaclient/_types.py @@ -13,7 +13,6 @@ # limitations under the License. """OTAClient internal used types.""" - from __future__ import annotations import multiprocessing.synchronize as mp_sync diff --git a/src/otaclient/_utils.py b/src/otaclient/_utils.py index 9fffe2c21..6c9ed6ba3 100644 --- a/src/otaclient/_utils.py +++ b/src/otaclient/_utils.py @@ -13,7 +13,6 @@ # limitations under the License. """Common shared utils, only used by otaclient package.""" - from __future__ import annotations import itertools diff --git a/src/otaclient/boot_control/_firmware_package.py b/src/otaclient/boot_control/_firmware_package.py index 4a2b89af0..552ca1a56 100644 --- a/src/otaclient/boot_control/_firmware_package.py +++ b/src/otaclient/boot_control/_firmware_package.py @@ -39,7 +39,6 @@ ``` """ - from __future__ import annotations import logging diff --git a/src/otaclient/boot_control/_grub.py b/src/otaclient/boot_control/_grub.py index 996764917..0effce543 100644 --- a/src/otaclient/boot_control/_grub.py +++ b/src/otaclient/boot_control/_grub.py @@ -30,7 +30,6 @@ still expecting new mechanism to fundamentally resolve this issue. """ - from __future__ import annotations import logging diff --git a/src/otaclient/boot_control/_jetson_cboot.py b/src/otaclient/boot_control/_jetson_cboot.py index 0c0bcd5d4..94e4c52f0 100644 --- a/src/otaclient/boot_control/_jetson_cboot.py +++ b/src/otaclient/boot_control/_jetson_cboot.py @@ -16,7 +16,6 @@ Supports BSP version < R34. """ - from __future__ import annotations import logging diff --git a/src/otaclient/boot_control/_jetson_common.py b/src/otaclient/boot_control/_jetson_common.py index b70c88874..30813baf4 100644 --- a/src/otaclient/boot_control/_jetson_common.py +++ b/src/otaclient/boot_control/_jetson_common.py @@ -16,7 +16,6 @@ This module is shared by jetson-cboot and jetson-uefi bootloader type. """ - from __future__ import annotations import logging diff --git a/src/otaclient/boot_control/_jetson_uefi.py b/src/otaclient/boot_control/_jetson_uefi.py index dd9a6523b..a10ac7ab8 100644 --- a/src/otaclient/boot_control/_jetson_uefi.py +++ b/src/otaclient/boot_control/_jetson_uefi.py @@ -17,7 +17,6 @@ But firmware update is only supported after BSP R35.2. """ - from __future__ import annotations import contextlib diff --git a/src/otaclient/boot_control/_ota_status_control.py b/src/otaclient/boot_control/_ota_status_control.py index 2d8f95519..740accaa5 100644 --- a/src/otaclient/boot_control/_ota_status_control.py +++ b/src/otaclient/boot_control/_ota_status_control.py @@ -13,7 +13,6 @@ # limitations under the License. """Shared utils for boot_controller.""" - from __future__ import annotations import contextlib diff --git a/src/otaclient/boot_control/_rpi_boot.py b/src/otaclient/boot_control/_rpi_boot.py index ace80c7b0..95e0a8e29 100644 --- a/src/otaclient/boot_control/_rpi_boot.py +++ b/src/otaclient/boot_control/_rpi_boot.py @@ -13,7 +13,6 @@ # limitations under the License. """Boot control support for Raspberry pi 4 Model B.""" - from __future__ import annotations import contextlib diff --git a/src/otaclient/boot_control/_slot_mnt_helper.py b/src/otaclient/boot_control/_slot_mnt_helper.py index 868850b57..e28ecd809 100644 --- a/src/otaclient/boot_control/_slot_mnt_helper.py +++ b/src/otaclient/boot_control/_slot_mnt_helper.py @@ -13,7 +13,6 @@ # limitations under the License. """Helper for mounting/umount slots during OTA.""" - from __future__ import annotations import atexit diff --git a/src/otaclient/configs/__init__.py b/src/otaclient/configs/__init__.py index a3da459e5..1f7574582 100644 --- a/src/otaclient/configs/__init__.py +++ b/src/otaclient/configs/__init__.py @@ -46,7 +46,6 @@ class DefaultOTAClientConfigs(ConfigurableSettings, Consts): else: class DefaultOTAClientConfigs: - def __init__(self) -> None: self._cfg_consts = Consts() self._cfg_configurable = ConfigurableSettings() diff --git a/src/otaclient/configs/_cfg_configurable.py b/src/otaclient/configs/_cfg_configurable.py index c1300d9fc..95bfbee1e 100644 --- a/src/otaclient/configs/_cfg_configurable.py +++ b/src/otaclient/configs/_cfg_configurable.py @@ -13,7 +13,6 @@ # limitations under the License. """Runtime configurable configs for otaclient.""" - from __future__ import annotations import logging diff --git a/src/otaclient/configs/_cfg_consts.py b/src/otaclient/configs/_cfg_consts.py index 9f2bc9c7f..a0d74374c 100644 --- a/src/otaclient/configs/_cfg_consts.py +++ b/src/otaclient/configs/_cfg_consts.py @@ -13,7 +13,6 @@ # limitations under the License. """otaclient internal uses consts, should not be changed from external.""" - from __future__ import annotations from otaclient_common import replace_root @@ -29,7 +28,6 @@ class CreateStandbyMechanism(StrEnum): class Consts: - CANONICAL_ROOT = CANONICAL_ROOT @property diff --git a/src/otaclient/configs/_ecu_info.py b/src/otaclient/configs/_ecu_info.py index c1ea4ad10..f9ce97152 100644 --- a/src/otaclient/configs/_ecu_info.py +++ b/src/otaclient/configs/_ecu_info.py @@ -13,7 +13,6 @@ # limitations under the License. """ECU metadatas definition and parsing logic.""" - from __future__ import annotations import logging diff --git a/src/otaclient/configs/_proxy_info.py b/src/otaclient/configs/_proxy_info.py index 4716ce09a..161272629 100644 --- a/src/otaclient/configs/_proxy_info.py +++ b/src/otaclient/configs/_proxy_info.py @@ -13,7 +13,6 @@ # limitations under the License. """proxy_info.yaml definition and parsing logic.""" - from __future__ import annotations import logging diff --git a/src/otaclient/configs/cfg.py b/src/otaclient/configs/cfg.py index 4071ce4b9..d7d03b10a 100644 --- a/src/otaclient/configs/cfg.py +++ b/src/otaclient/configs/cfg.py @@ -46,7 +46,6 @@ class _OTAClientConfigs(ConfigurableSettings, Consts): else: class _OTAClientConfigs: - # NOTE(20241108): still use __getattr__ to allow changing/mocking attributes # for easy testing. def __getattr__(self, name: str) -> Any: diff --git a/src/otaclient/create_standby/common.py b/src/otaclient/create_standby/common.py index 55643a882..a1be33cfb 100644 --- a/src/otaclient/create_standby/common.py +++ b/src/otaclient/create_standby/common.py @@ -13,7 +13,6 @@ # limitations under the License. """Common used helpers, classes and functions for different bank creating methods.""" - from __future__ import annotations import contextlib diff --git a/src/otaclient/create_standby/interface.py b/src/otaclient/create_standby/interface.py index 4509b8138..64b8159c3 100644 --- a/src/otaclient/create_standby/interface.py +++ b/src/otaclient/create_standby/interface.py @@ -29,7 +29,6 @@ update to the standby slot. """ - from __future__ import annotations from abc import abstractmethod diff --git a/src/otaclient/errors.py b/src/otaclient/errors.py index 52b5ce23e..f0415813f 100644 --- a/src/otaclient/errors.py +++ b/src/otaclient/errors.py @@ -13,7 +13,6 @@ # limitations under the License. """OTA error code definition""" - from __future__ import annotations from enum import Enum, unique diff --git a/src/otaclient/grpc/api_v2/ecu_status.py b/src/otaclient/grpc/api_v2/ecu_status.py index 66b8b68b3..635889c1a 100644 --- a/src/otaclient/grpc/api_v2/ecu_status.py +++ b/src/otaclient/grpc/api_v2/ecu_status.py @@ -36,7 +36,6 @@ any_requires_network, all_success, in_update_ecus_id, failed_ecus_id, success_ecus_id and in_update_childecus_id. """ - from __future__ import annotations import asyncio @@ -82,7 +81,6 @@ def discard(self, value: T): class ECUStatusStorage: - def __init__( self, *, diff --git a/src/otaclient/grpc/api_v2/ecu_tracker.py b/src/otaclient/grpc/api_v2/ecu_tracker.py index ba454f138..fec2b5814 100644 --- a/src/otaclient/grpc/api_v2/ecu_tracker.py +++ b/src/otaclient/grpc/api_v2/ecu_tracker.py @@ -13,7 +13,6 @@ # limitations under the License. """Tracker that queries and stores ECU status from all defined ECUs.""" - from __future__ import annotations import asyncio @@ -48,7 +47,6 @@ class ECUTracker: - def __init__( self, ecu_status_storage: ECUStatusStorage, diff --git a/src/otaclient/grpc/api_v2/main.py b/src/otaclient/grpc/api_v2/main.py index 38ca6481d..811e72306 100644 --- a/src/otaclient/grpc/api_v2/main.py +++ b/src/otaclient/grpc/api_v2/main.py @@ -13,7 +13,6 @@ # limitations under the License. """Main entry for OTA API v2 grpc server.""" - from __future__ import annotations import asyncio diff --git a/src/otaclient/grpc/api_v2/servicer.py b/src/otaclient/grpc/api_v2/servicer.py index a44ccb1a5..0da7a1970 100644 --- a/src/otaclient/grpc/api_v2/servicer.py +++ b/src/otaclient/grpc/api_v2/servicer.py @@ -13,7 +13,6 @@ # limitations under the License. """OTA Service API v2 implementation.""" - from __future__ import annotations import asyncio diff --git a/src/otaclient/grpc/api_v2/types.py b/src/otaclient/grpc/api_v2/types.py index 208672248..35cc690aa 100644 --- a/src/otaclient/grpc/api_v2/types.py +++ b/src/otaclient/grpc/api_v2/types.py @@ -13,7 +13,6 @@ # limitations under the License. """Helpers for converting otaclient internal used types into api_v2 types.""" - from __future__ import annotations import time diff --git a/src/otaclient/main.py b/src/otaclient/main.py index 4d0316993..4ae9ba6d9 100644 --- a/src/otaclient/main.py +++ b/src/otaclient/main.py @@ -13,7 +13,6 @@ # limitations under the License. """Entrypoint of otaclient.""" - from __future__ import annotations import atexit diff --git a/src/otaclient/ota_core.py b/src/otaclient/ota_core.py index 77696ff64..b8f04eb9c 100644 --- a/src/otaclient/ota_core.py +++ b/src/otaclient/ota_core.py @@ -628,7 +628,6 @@ def execute(self): class OTAClient: - def __init__( self, *, @@ -840,7 +839,6 @@ def main( ) elif isinstance(request, UpdateRequestV2): - _update_thread = threading.Thread( target=self.update, args=[request], @@ -877,7 +875,6 @@ def main( ) _allow_request_after = _now + HOLD_REQ_HANDLING_ON_ACK_REQUEST else: - _err_msg = f"request is invalid: {request=}, {self._live_ota_status=}" logger.error(_err_msg) resp_queue.put_nowait( diff --git a/src/otaclient_api/v2/api_caller.py b/src/otaclient_api/v2/api_caller.py index bcf6031b6..5cad51559 100644 --- a/src/otaclient_api/v2/api_caller.py +++ b/src/otaclient_api/v2/api_caller.py @@ -13,7 +13,6 @@ # limitations under the License. """OTAClient API caller implementation.""" - from __future__ import annotations import grpc.aio diff --git a/src/otaclient_api/v2/types.py b/src/otaclient_api/v2/types.py index f784a568c..d0c978a3c 100644 --- a/src/otaclient_api/v2/types.py +++ b/src/otaclient_api/v2/types.py @@ -13,7 +13,6 @@ # limitations under the License. """Defined wrappers for otaclient_v2 protobuf message types.""" - from __future__ import annotations from abc import abstractmethod diff --git a/src/otaclient_common/__init__.py b/src/otaclient_common/__init__.py index 56ffe96c6..e708dfd41 100644 --- a/src/otaclient_common/__init__.py +++ b/src/otaclient_common/__init__.py @@ -13,7 +13,6 @@ # limitations under the License. """Common shared libs for otaclient.""" - from __future__ import annotations import importlib.util diff --git a/src/otaclient_common/_io.py b/src/otaclient_common/_io.py index 53bec792c..eef99d9da 100644 --- a/src/otaclient_common/_io.py +++ b/src/otaclient_common/_io.py @@ -13,7 +13,6 @@ # limitations under the License. """Common shared helper functions for IO.""" - from __future__ import annotations import hashlib diff --git a/src/otaclient_common/cmdhelper.py b/src/otaclient_common/cmdhelper.py index 21af23af7..d8c2b248f 100644 --- a/src/otaclient_common/cmdhelper.py +++ b/src/otaclient_common/cmdhelper.py @@ -18,7 +18,6 @@ to the upper caller. """ - from __future__ import annotations import logging diff --git a/src/otaclient_common/common.py b/src/otaclient_common/common.py index 0cb007c47..d3b7607fa 100644 --- a/src/otaclient_common/common.py +++ b/src/otaclient_common/common.py @@ -17,7 +17,6 @@ the future. """ - from __future__ import annotations import logging diff --git a/src/otaclient_common/downloader.py b/src/otaclient_common/downloader.py index d460b2c8b..361428dca 100644 --- a/src/otaclient_common/downloader.py +++ b/src/otaclient_common/downloader.py @@ -16,7 +16,6 @@ This downloader implements the OTA-Cache-File-Control protocol to co-operate with otaproxy. """ - from __future__ import annotations import hashlib @@ -238,7 +237,6 @@ def _wrapper(*args: P.args, **kwargs: P.kwargs) -> T: class Downloader: - def __init__( self, *, diff --git a/src/otaclient_common/proto_streamer.py b/src/otaclient_common/proto_streamer.py index e52934730..7e2454272 100644 --- a/src/otaclient_common/proto_streamer.py +++ b/src/otaclient_common/proto_streamer.py @@ -20,7 +20,6 @@ Which will be 4 bytes unsigned int in big-endian layout. """ - from typing import BinaryIO, Generic, Iterable, Optional, Type from otaclient_common.proto_wrapper import MessageType, MessageWrapperType diff --git a/src/otaclient_common/retry_task_map.py b/src/otaclient_common/retry_task_map.py index 5d71b6623..bc1b6702f 100644 --- a/src/otaclient_common/retry_task_map.py +++ b/src/otaclient_common/retry_task_map.py @@ -44,7 +44,6 @@ class TasksEnsureFailed(Exception): class _ThreadPoolExecutorWithRetry(ThreadPoolExecutor): - def __init__( self, max_concurrent: int, @@ -259,7 +258,6 @@ def _dispatcher() -> None: if TYPE_CHECKING: class ThreadPoolExecutorWithRetry: - def __init__( self, max_concurrent: int, diff --git a/src/otaclient_common/shm_status.py b/src/otaclient_common/shm_status.py index 4dc7e025a..02b2f9535 100644 --- a/src/otaclient_common/shm_status.py +++ b/src/otaclient_common/shm_status.py @@ -19,7 +19,6 @@ In which, msg is pickled python object. """ - from __future__ import annotations import hashlib @@ -85,7 +84,6 @@ def _ensure_connect_shm( class MPSharedStatusReader(SHA512Verifier, Generic[T]): - def __init__( self, *, @@ -140,7 +138,6 @@ def sync_msg(self) -> T: class MPSharedStatusWriter(SHA512Verifier, Generic[T]): - def __init__( self, *, diff --git a/src/otaclient_common/typing.py b/src/otaclient_common/typing.py index 605e73b2d..d8a57ffcc 100644 --- a/src/otaclient_common/typing.py +++ b/src/otaclient_common/typing.py @@ -52,7 +52,6 @@ # besides here, we implement __str__ to use str type's one, to align with # the behavior of >= 3.11. class StrEnum(str, Enum): - def __str__(self) -> str: return str.__str__(self) diff --git a/tests/test_ota_proxy/test_cache_streaming.py b/tests/test_ota_proxy/test_cache_streaming.py index 8efdbcd1c..ed307f8b0 100644 --- a/tests/test_ota_proxy/test_cache_streaming.py +++ b/tests/test_ota_proxy/test_cache_streaming.py @@ -133,7 +133,9 @@ async def test_ongoing_cache_register(self): # start all the worker, all the workers will now access the same resouce. self.sync_event.set() logger.info("all workers start to subscribe to the register") - await self._wait_for_registeration_finish() # wait for all workers finish subscribing + await ( + self._wait_for_registeration_finish() + ) # wait for all workers finish subscribing self.writer_done_event.set() # writer finished ###### check the test result ###### diff --git a/tests/test_ota_proxy/test_ota_cache.py b/tests/test_ota_proxy/test_ota_cache.py index d00baa181..356a90846 100644 --- a/tests/test_ota_proxy/test_ota_cache.py +++ b/tests/test_ota_proxy/test_ota_cache.py @@ -78,7 +78,6 @@ def entries_to_remove(setup_testdata: dict[str, CacheMeta]) -> list[CacheMeta]: @pytest.mark.asyncio(scope="class") class TestLRUCacheHelper: - @pytest_asyncio.fixture(autouse=True, scope="class") async def lru_helper(self, tmp_path_factory: pytest.TempPathFactory): ota_cache_folder = tmp_path_factory.mktemp("ota-cache") diff --git a/tests/test_otaclient/test_boot_control/test_jetson_common.py b/tests/test_otaclient/test_boot_control/test_jetson_common.py index 884447c53..9399bcd26 100644 --- a/tests/test_otaclient/test_boot_control/test_jetson_common.py +++ b/tests/test_otaclient/test_boot_control/test_jetson_common.py @@ -13,7 +13,6 @@ # limitations under the License. """Tests for Jetson device boot control implementation common.""" - from __future__ import annotations from pathlib import Path @@ -61,7 +60,6 @@ def _test(): class TestBSPVersion: - @pytest.mark.parametrize( "_in, _expect, _exc", ( @@ -99,7 +97,6 @@ def test_dump(self, _in: BSPVersion, _expect: str): class TestSlotBSPVersion: - @pytest.mark.parametrize( "_in, _slot, _bsp_ver, _expect", ( @@ -182,7 +179,6 @@ def test_load_and_dump(self, _in: SlotBSPVersion): class TestFirmwareBSPVersionControl: - @pytest.fixture(autouse=True) def setup_test(self, tmp_path: Path): self.test_fw_bsp_vf = tmp_path / "firmware_bsp_version" diff --git a/tests/test_otaclient/test_boot_control/test_jetson_uefi.py b/tests/test_otaclient/test_boot_control/test_jetson_uefi.py index 72b821856..d10f731de 100644 --- a/tests/test_otaclient/test_boot_control/test_jetson_uefi.py +++ b/tests/test_otaclient/test_boot_control/test_jetson_uefi.py @@ -39,7 +39,6 @@ class TestNVBootctrlJetsonUEFI: - @pytest.mark.parametrize( "_input, expected", ( @@ -204,7 +203,6 @@ def test__detect_ota_bootdev_is_qspi(nvbootctrl_conf, expected): class TestL4TLauncherBSPVersionControl: - @pytest.mark.parametrize( "_in, expected", _test_case := ( diff --git a/tests/test_otaclient/test_create_standby.py b/tests/test_otaclient/test_create_standby.py index b0abbbec8..68f7cff66 100644 --- a/tests/test_otaclient/test_create_standby.py +++ b/tests/test_otaclient/test_create_standby.py @@ -83,7 +83,6 @@ def prepare_ab_slots(self, tmp_path: Path, ab_slots: SlotMeta): @pytest.fixture(autouse=True) def mock_setup(self, mocker: MockerFixture, prepare_ab_slots): - # ------ mock boot_controller ------ # self._boot_control = typing.cast( BootControllerProtocol, mocker.MagicMock(spec=BootControllerProtocol) diff --git a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py index 8e3081f8d..cd415dc5f 100644 --- a/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py +++ b/tests/test_otaclient/test_grpc/test_api_v2/test_ecu_status.py @@ -61,7 +61,9 @@ async def setup_test(self, mocker: MockerFixture, ecu_info_fixture: ECUInfo): _mocked_otaclient_cfg = DefaultOTAClientConfigs() # NOTE: decrease the interval for faster testing - _mocked_otaclient_cfg.OVERALL_ECUS_STATUS_UPDATE_INTERVAL = self.PROPERTY_REFRESH_INTERVAL_FOR_TEST # type: ignore[assignment] + _mocked_otaclient_cfg.OVERALL_ECUS_STATUS_UPDATE_INTERVAL = ( + self.PROPERTY_REFRESH_INTERVAL_FOR_TEST + ) # type: ignore[assignment] mocker.patch(f"{ECU_STATUS_MODULE}.cfg", _mocked_otaclient_cfg) try: diff --git a/tests/test_otaclient/test_status_monitor.py b/tests/test_otaclient/test_status_monitor.py index 411927e24..f49cd291d 100644 --- a/tests/test_otaclient/test_status_monitor.py +++ b/tests/test_otaclient/test_status_monitor.py @@ -13,7 +13,6 @@ # limitations under the License. """The implementation of tracking otaclient operation stats.""" - from __future__ import annotations import logging @@ -37,7 +36,6 @@ class TestStatusMonitor: - # update meta TOTAL_FILES_NUM = TOTAL_FILES_SIZE = 1000 METADATA_SIZE = 20 diff --git a/tests/test_otaclient/test_utils.py b/tests/test_otaclient/test_utils.py index 0ffed4e0f..f0eb42646 100644 --- a/tests/test_otaclient/test_utils.py +++ b/tests/test_otaclient/test_utils.py @@ -26,7 +26,6 @@ class _TickingFlag: - def __init__(self, trigger_in: int) -> None: self._trigger_time = time.time() + trigger_in diff --git a/tests/test_otaclient_api/test_v2/test_types.py b/tests/test_otaclient_api/test_v2/test_types.py index e51f03649..60c295bc3 100644 --- a/tests/test_otaclient_api/test_v2/test_types.py +++ b/tests/test_otaclient_api/test_v2/test_types.py @@ -163,8 +163,11 @@ def test_direct_compare(self): def test_assign_to_protobuf_message(self): """wrapper enum can be directly assigned in protobuf message.""" - left, r = v2.StatusProgress(phase=v2.REGULAR), v2.StatusProgress( - phase=api_types.StatusProgressPhase.REGULAR.value, # type: ignore + left, r = ( + v2.StatusProgress(phase=v2.REGULAR), + v2.StatusProgress( + phase=api_types.StatusProgressPhase.REGULAR.value, # type: ignore + ), ) compare_message(left, r) diff --git a/tests/test_otaclient_common/test_downloader.py b/tests/test_otaclient_common/test_downloader.py index 23a0c5131..700b11fdd 100644 --- a/tests/test_otaclient_common/test_downloader.py +++ b/tests/test_otaclient_common/test_downloader.py @@ -162,7 +162,6 @@ def _dummy_logger(*args, **kwargs): class TestDownloader: - @pytest.fixture(autouse=True) def setup_downloader(self, tmp_path: Path): self.downloader = Downloader(hash_func=sha256, chunk_size=4096) @@ -174,7 +173,6 @@ def test_req_inject_cache_control_headers( mocker: pytest_mock.MockerFixture, tmp_path: Path, ): - class _ControlledException(Exception): """For breakout the actual downloading.""" @@ -428,7 +426,6 @@ def test_check_cache_policy_in_resp( class TestDownloadingPoolWatchdog: - @pytest.fixture(autouse=True) def setup_test(self): self._test_started_timestamp = 0 diff --git a/tests/test_otaclient_common/test_io.py b/tests/test_otaclient_common/test_io.py index a6f89ce7f..d0eed7e33 100644 --- a/tests/test_otaclient_common/test_io.py +++ b/tests/test_otaclient_common/test_io.py @@ -60,7 +60,6 @@ def test_gen_file_digest(tmp_path: Path): class TestWriteStrToFileAtomic: - @pytest.fixture(scope="class") def data(self): data_lens = [100, 500, 1000, 9000] # bytes diff --git a/tests/test_otaclient_common/test_retry_task_map.py b/tests/test_otaclient_common/test_retry_task_map.py index ca65e2304..3bd7edb3a 100644 --- a/tests/test_otaclient_common/test_retry_task_map.py +++ b/tests/test_otaclient_common/test_retry_task_map.py @@ -47,7 +47,6 @@ def _thread_initializer(msg: str) -> None: class TestRetryTaskMap: - @pytest.fixture(autouse=True) def setup(self) -> None: self._start_time = time.time() diff --git a/tools/local_ota/api_v2.py b/tools/local_ota/api_v2.py index a938df0d9..2e1ec16a6 100644 --- a/tools/local_ota/api_v2.py +++ b/tools/local_ota/api_v2.py @@ -13,7 +13,6 @@ # limitations under the License. """A simple tool to trigger an OTA locally, for API version 2.""" - from __future__ import annotations import argparse diff --git a/tools/offline_ota_image_builder/__main__.py b/tools/offline_ota_image_builder/__main__.py index 8a5ab15ba..09d41e41f 100644 --- a/tools/offline_ota_image_builder/__main__.py +++ b/tools/offline_ota_image_builder/__main__.py @@ -36,7 +36,6 @@ Please refer to OTA cache design doc for more details. """ - import argparse import errno import logging diff --git a/tools/offline_ota_image_builder/manifest.py b/tools/offline_ota_image_builder/manifest.py index ca9ef0067..22800631f 100644 --- a/tools/offline_ota_image_builder/manifest.py +++ b/tools/offline_ota_image_builder/manifest.py @@ -19,7 +19,6 @@ Check README.md for the spec. """ - import json from dataclasses import asdict, dataclass, field from typing import List diff --git a/tools/offline_ota_image_builder/utils.py b/tools/offline_ota_image_builder/utils.py index c8373cec7..5f668d71a 100644 --- a/tools/offline_ota_image_builder/utils.py +++ b/tools/offline_ota_image_builder/utils.py @@ -13,7 +13,6 @@ # limitations under the License. """Shared utils among package.""" - from os import PathLike from typing import Union