From 97b434530338beac52763c158f4e94f38ba55d55 Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Tue, 2 Apr 2024 11:21:28 +0400 Subject: [PATCH] build: use latest images of RPi as base images fix(keypad): make keypad compatible with kernel 6.6 by using gpiozero ci: use latest versions of ruff and pyright --- .github/workflows/integration_delivery.yml | 4 +- CHANGELOG.md | 2 + poetry.lock | 44 +++++++++---------- pyproject.toml | 3 +- scripts/print_version.py | 1 + tests/fixtures/app.py | 4 +- tests/fixtures/load_services.py | 5 +-- tests/fixtures/snapshot.py | 3 +- tests/monkeypatch.py | 6 +-- tests/utils/import_tracker.py | 4 +- ubo_app/load_services.py | 3 +- ubo_app/logging.py | 5 ++- ubo_app/menu_central.py | 4 +- ubo_app/menu_footer.py | 6 ++- ubo_app/services.py | 3 +- ubo_app/services/000-sound/audio_manager.py | 36 ++++++++------- ubo_app/services/020-keypad/setup.py | 3 +- .../services/030-ethernet/ethernet_manager.py | 3 +- ubo_app/services/030-ip/setup.py | 5 ++- .../pages/create_wireless_connection.py | 5 ++- ubo_app/services/030-wifi/pages/main.py | 5 ++- ubo_app/services/030-wifi/wifi_manager.py | 3 +- .../services/040-rgb-ring/rgb_ring_client.py | 5 ++- ubo_app/services/040-sensors/reducer.py | 1 + ubo_app/services/040-sensors/setup.py | 6 +-- ubo_app/services/050-lightdm/setup.py | 4 +- ubo_app/services/050-ssh/setup.py | 8 ++-- ubo_app/services/080-docker/image.py | 5 ++- ubo_app/services/080-docker/reducer.py | 5 ++- ubo_app/services/080-docker/setup.py | 5 ++- ubo_app/side_effects.py | 4 +- ubo_app/store/__init__.py | 4 +- ubo_app/store/main/__init__.py | 6 ++- ubo_app/store/main/_menus.py | 8 ++-- ubo_app/store/main/reducer.py | 3 +- ubo_app/store/services/docker.py | 1 + ubo_app/store/services/ip.py | 14 +++--- ubo_app/store/services/keypad.py | 12 ++--- ubo_app/store/services/notifications.py | 9 ++-- ubo_app/store/services/rgb_ring.py | 18 +++----- ubo_app/store/services/sensors.py | 3 +- ubo_app/store/services/sound.py | 6 +-- ubo_app/store/services/wifi.py | 5 ++- ubo_app/store/status_icons/__init__.py | 8 ++-- ubo_app/store/update_manager/__init__.py | 12 ++--- ubo_app/store/update_manager/utils.py | 11 +++-- .../clear_all_temporary_accounts.sh | 2 +- .../create_temporary_ssh_account.sh | 2 +- ubo_app/system/system_manager/led.py | 4 +- .../system/system_manager/service_manager.py | 8 ++-- ubo_app/utils/async_.py | 3 +- ubo_app/utils/fake.py | 5 ++- ubo_app/utils/garbage_collection.py | 3 +- ubo_app/utils/loop.py | 3 +- ubo_app/utils/monitor_unit.py | 5 ++- ubo_app/utils/qrcode.py | 9 ++-- 56 files changed, 217 insertions(+), 147 deletions(-) diff --git a/.github/workflows/integration_delivery.yml b/.github/workflows/integration_delivery.yml index e2a9a4b5..95ce34b9 100644 --- a/.github/workflows/integration_delivery.yml +++ b/.github/workflows/integration_delivery.yml @@ -125,7 +125,7 @@ jobs: - name: Run Tests run: | - mkdir -p $HOME/.kiv/mods + mkdir -p $HOME/.kivy/mods poetry run poe test --make-screenshots --cov-report=xml --cov-report=html -n auto --log-level=DEBUG - name: Collect Window Screenshots @@ -290,7 +290,7 @@ jobs: SUFFIX="${{ matrix.suffix }}" fi DASHED_SUFFIX=$(echo $SUFFIX | sed 's/_/-/g') - IMAGE_URL="https://downloads.raspberrypi.com/raspios${SUFFIX}_arm64/images/raspios${SUFFIX}_arm64-2023-12-06/2023-12-05-raspios-bookworm-arm64${DASHED_SUFFIX}.img.xz" + IMAGE_URL="https://downloads.raspberrypi.com/raspios${SUFFIX}_arm64/images/raspios${SUFFIX}_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64${DASHED_SUFFIX}.img.xz" IMAGE_CHECKSUM=$(curl -s "${IMAGE_URL}.sha256" | awk '{print $1}') echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT" echo "dashed_suffix=$DASHED_SUFFIX" >> "$GITHUB_OUTPUT" diff --git a/CHANGELOG.md b/CHANGELOG.md index e92313fc..dfccc64f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## Version 0.12.3 +- build: use latest images of RPi as base images - fix(keypad): make keypad compatible with kernel 6.6 by using gpiozero +- ci: use latest versions of ruff and pyright ## Version 0.12.2 diff --git a/poetry.lock b/poetry.lock index 2935cea9..b1aa04d1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -126,13 +126,13 @@ typing-extensions = ">=4.0,<5.0" [[package]] name = "adafruit-circuitpython-requests" -version = "3.2.2" +version = "3.2.3" description = "A requests-like library for web interfacing" optional = false python-versions = "*" files = [ - {file = "adafruit-circuitpython-requests-3.2.2.tar.gz", hash = "sha256:57fabbeebed2f4dd9a7a860341a70d94d748030f9dc1b4d5df35a1b599cfb3ad"}, - {file = "adafruit_circuitpython_requests-3.2.2-py3-none-any.whl", hash = "sha256:474efb9349e9e7d6100cbc78bfbd88ca0aca4f630eff2bd4808db8b05512a859"}, + {file = "adafruit-circuitpython-requests-3.2.3.tar.gz", hash = "sha256:93e828c7eefa365e2d7108144d43facf57317aebe3cc6c1f5584d600239e2042"}, + {file = "adafruit_circuitpython_requests-3.2.3-py3-none-any.whl", hash = "sha256:93b61cbb82d5b8014471dc2f71e21cd202dddb4355f823c65b198949144cdf8f"}, ] [package.dependencies] @@ -1556,28 +1556,28 @@ files = [ [[package]] name = "ruff" -version = "0.3.4" +version = "0.3.5" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:60c870a7d46efcbc8385d27ec07fe534ac32f3b251e4fc44b3cbfd9e09609ef4"}, - {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6fc14fa742e1d8f24910e1fff0bd5e26d395b0e0e04cc1b15c7c5e5fe5b4af91"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3ee7880f653cc03749a3bfea720cf2a192e4f884925b0cf7eecce82f0ce5854"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cf133dd744f2470b347f602452a88e70dadfbe0fcfb5fd46e093d55da65f82f7"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f3860057590e810c7ffea75669bdc6927bfd91e29b4baa9258fd48b540a4365"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:986f2377f7cf12efac1f515fc1a5b753c000ed1e0a6de96747cdf2da20a1b369"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4fd98e85869603e65f554fdc5cddf0712e352fe6e61d29d5a6fe087ec82b76c"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:64abeed785dad51801b423fa51840b1764b35d6c461ea8caef9cf9e5e5ab34d9"}, - {file = "ruff-0.3.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df52972138318bc7546d92348a1ee58449bc3f9eaf0db278906eb511889c4b50"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:98e98300056445ba2cc27d0b325fd044dc17fcc38e4e4d2c7711585bd0a958ed"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:519cf6a0ebed244dce1dc8aecd3dc99add7a2ee15bb68cf19588bb5bf58e0488"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:bb0acfb921030d00070539c038cd24bb1df73a2981e9f55942514af8b17be94e"}, - {file = "ruff-0.3.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:cf187a7e7098233d0d0c71175375c5162f880126c4c716fa28a8ac418dcf3378"}, - {file = "ruff-0.3.4-py3-none-win32.whl", hash = "sha256:af27ac187c0a331e8ef91d84bf1c3c6a5dea97e912a7560ac0cef25c526a4102"}, - {file = "ruff-0.3.4-py3-none-win_amd64.whl", hash = "sha256:de0d5069b165e5a32b3c6ffbb81c350b1e3d3483347196ffdf86dc0ef9e37dd6"}, - {file = "ruff-0.3.4-py3-none-win_arm64.whl", hash = "sha256:6810563cc08ad0096b57c717bd78aeac888a1bfd38654d9113cb3dc4d3f74232"}, - {file = "ruff-0.3.4.tar.gz", hash = "sha256:f0f4484c6541a99862b693e13a151435a279b271cff20e37101116a21e2a1ad1"}, + {file = "ruff-0.3.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:aef5bd3b89e657007e1be6b16553c8813b221ff6d92c7526b7e0227450981eac"}, + {file = "ruff-0.3.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:89b1e92b3bd9fca249153a97d23f29bed3992cff414b222fcd361d763fc53f12"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e55771559c89272c3ebab23326dc23e7f813e492052391fe7950c1a5a139d89"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dabc62195bf54b8a7876add6e789caae0268f34582333cda340497c886111c39"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3a05f3793ba25f194f395578579c546ca5d83e0195f992edc32e5907d142bfa3"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:dfd3504e881082959b4160ab02f7a205f0fadc0a9619cc481982b6837b2fd4c0"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:87258e0d4b04046cf1d6cc1c56fadbf7a880cc3de1f7294938e923234cf9e498"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:712e71283fc7d9f95047ed5f793bc019b0b0a29849b14664a60fd66c23b96da1"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a532a90b4a18d3f722c124c513ffb5e5eaff0cc4f6d3aa4bda38e691b8600c9f"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:122de171a147c76ada00f76df533b54676f6e321e61bd8656ae54be326c10296"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d80a6b18a6c3b6ed25b71b05eba183f37d9bc8b16ace9e3d700997f00b74660b"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a7b6e63194c68bca8e71f81de30cfa6f58ff70393cf45aab4c20f158227d5936"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a759d33a20c72f2dfa54dae6e85e1225b8e302e8ac655773aff22e542a300985"}, + {file = "ruff-0.3.5-py3-none-win32.whl", hash = "sha256:9d8605aa990045517c911726d21293ef4baa64f87265896e491a05461cae078d"}, + {file = "ruff-0.3.5-py3-none-win_amd64.whl", hash = "sha256:dc56bb16a63c1303bd47563c60482a1512721053d93231cf7e9e1c6954395a0e"}, + {file = "ruff-0.3.5-py3-none-win_arm64.whl", hash = "sha256:faeeae9905446b975dcf6d4499dc93439b131f1443ee264055c5716dd947af55"}, + {file = "ruff-0.3.5.tar.gz", hash = "sha256:a067daaeb1dc2baf9b82a32dae67d154d95212080c80435eb052d95da647763d"}, ] [[package]] @@ -1891,4 +1891,4 @@ dev = ["ubo-gui", "ubo-gui"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "556143de7c94c63e9cc8c06f18aa3bfda7e6f91df9fe7af27fd6768d1d7ab11f" +content-hash = "8b8f6e84e775729cf8be27ce2a8067d17a7f42432efdcc85215958fff91b5374" diff --git a/pyproject.toml b/pyproject.toml index a692966b..f882266d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ pytest-asyncio = "^0.23.5.post1" pytest-cov = "^4.1.0" pytest-timeout = "^2.3.1" pytest-xdist = "^3.5.0" -ruff = "^0.3.4" +ruff = "^0.3.5" tenacity = "^8.2.3" toml = "^0.10.2" pytest-mock = "^3.14.0" @@ -88,6 +88,7 @@ lint.select = ["ALL"] lint.ignore = ["INP001", "PLR0911", "D203", "D213"] lint.fixable = ["ALL"] lint.unfixable = [] +target-version = 'py311' [tool.ruff.lint.flake8-builtins] builtins-ignorelist = ["type", "id"] diff --git a/scripts/print_version.py b/scripts/print_version.py index 7da42f67..eef2c043 100644 --- a/scripts/print_version.py +++ b/scripts/print_version.py @@ -1,4 +1,5 @@ """Prints the version of the ubo_app package.""" + import importlib.metadata print(importlib.metadata.version('ubo_app'), sep='', end='') # noqa: T201 diff --git a/tests/fixtures/app.py b/tests/fixtures/app.py index 737840ac..5aad823c 100644 --- a/tests/fixtures/app.py +++ b/tests/fixtures/app.py @@ -8,13 +8,15 @@ import logging import sys import weakref -from typing import TYPE_CHECKING, AsyncGenerator +from typing import TYPE_CHECKING import pytest from ubo_app.setup import setup if TYPE_CHECKING: + from collections.abc import AsyncGenerator + from _pytest.fixtures import SubRequest from ubo_app.menu import MenuApp diff --git a/tests/fixtures/load_services.py b/tests/fixtures/load_services.py index 74cd5e4f..e071b8c0 100644 --- a/tests/fixtures/load_services.py +++ b/tests/fixtures/load_services.py @@ -4,11 +4,8 @@ from typing import ( TYPE_CHECKING, - Coroutine, - Generator, Literal, Protocol, - Sequence, cast, overload, ) @@ -16,6 +13,8 @@ import pytest if TYPE_CHECKING: + from collections.abc import Coroutine, Generator, Sequence + from tests.conftest import WaitFor diff --git a/tests/fixtures/snapshot.py b/tests/fixtures/snapshot.py index 68cac490..463a216b 100644 --- a/tests/fixtures/snapshot.py +++ b/tests/fixtures/snapshot.py @@ -4,11 +4,12 @@ import os from collections import defaultdict -from typing import TYPE_CHECKING, Any, Generator, cast +from typing import TYPE_CHECKING, Any, cast import pytest if TYPE_CHECKING: + from collections.abc import Generator from pathlib import Path from _pytest.fixtures import SubRequest diff --git a/tests/monkeypatch.py b/tests/monkeypatch.py index 60dffd52..2df5133e 100644 --- a/tests/monkeypatch.py +++ b/tests/monkeypatch.py @@ -75,7 +75,7 @@ class DateTime(datetime.datetime): @classmethod def now(cls: type[DateTime], tz: datetime.tzinfo | None = None) -> DateTime: _ = tz - return DateTime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc) + return DateTime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.UTC) monkeypatch.setattr(datetime, 'datetime', DateTime) @@ -188,9 +188,9 @@ async def fake_create_subprocess_exec( **kwargs: object, ) -> FakeAsyncProcess: _ = kwargs - if command == '/usr/bin/env' and args == ('systemctl', 'is-enabled', 'sshd'): + if command == '/usr/bin/env' and args == ('systemctl', 'is-enabled', 'ssh'): return FakeAsyncProcess(output=b'enabled') - if command == '/usr/bin/env' and args == ('systemctl', 'is-active', 'sshd'): + if command == '/usr/bin/env' and args == ('systemctl', 'is-active', 'ssh'): return FakeAsyncProcess(output=b'active') if command == '/usr/bin/env' and args == ('systemctl', 'is-enabled', 'lightdm'): return FakeAsyncProcess(output=b'enabled') diff --git a/tests/utils/import_tracker.py b/tests/utils/import_tracker.py index d68c6ec4..47ed3280 100644 --- a/tests/utils/import_tracker.py +++ b/tests/utils/import_tracker.py @@ -1,12 +1,14 @@ """A module to track imports of other modules.""" + from __future__ import annotations import importlib.abc import sys from dataclasses import dataclass -from typing import TYPE_CHECKING, Callable, Sequence +from typing import TYPE_CHECKING if TYPE_CHECKING: + from collections.abc import Callable, Sequence from types import ModuleType diff --git a/ubo_app/load_services.py b/ubo_app/load_services.py index 20938a8a..8ae5e0a7 100644 --- a/ubo_app/load_services.py +++ b/ubo_app/load_services.py @@ -11,9 +11,10 @@ import threading import traceback import uuid +from collections.abc import Callable, Sequence from importlib.machinery import PathFinder, SourceFileLoader from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, ClassVar, Sequence, cast +from typing import TYPE_CHECKING, Any, ClassVar, cast from redux import CombineReducerRegisterAction, ReducerType diff --git a/ubo_app/logging.py b/ubo_app/logging.py index 53d01aaa..6d10e9e2 100644 --- a/ubo_app/logging.py +++ b/ubo_app/logging.py @@ -5,7 +5,10 @@ import json import logging import sys -from typing import Mapping, cast +from typing import TYPE_CHECKING, cast + +if TYPE_CHECKING: + from collections.abc import Mapping VERBOSE = 5 diff --git a/ubo_app/menu_central.py b/ubo_app/menu_central.py index 788e326d..22b2b1d4 100644 --- a/ubo_app/menu_central.py +++ b/ubo_app/menu_central.py @@ -4,7 +4,7 @@ import pathlib import weakref from functools import cached_property -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from debouncer import DebounceOptions, debounce from kivy.clock import Clock, mainthread @@ -27,6 +27,8 @@ from .store import autorun, dispatch, subscribe_event if TYPE_CHECKING: + from collections.abc import Sequence + from kivy.uix.widget import Widget from ubo_gui.menu.types import Item, Menu diff --git a/ubo_app/menu_footer.py b/ubo_app/menu_footer.py index bcefaf6a..bdc76bad 100644 --- a/ubo_app/menu_footer.py +++ b/ubo_app/menu_footer.py @@ -3,7 +3,7 @@ import datetime from functools import cached_property -from typing import TYPE_CHECKING, Any, Sequence +from typing import TYPE_CHECKING, Any from kivy.clock import Clock from kivy.metrics import dp @@ -17,6 +17,8 @@ from ubo_app.store import autorun if TYPE_CHECKING: + from collections.abc import Sequence + from ubo_app.store.status_icons import IconState @@ -106,7 +108,7 @@ def clock_widget(self: MenuAppFooter) -> Label: texture_size[0], ), ) - local_timzone = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo + local_timzone = datetime.datetime.now(datetime.UTC).astimezone().tzinfo def now() -> datetime.datetime: return datetime.datetime.now(local_timzone) diff --git a/ubo_app/services.py b/ubo_app/services.py index 442017ab..c8fe1d2b 100644 --- a/ubo_app/services.py +++ b/ubo_app/services.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable, Coroutine, Protocol, TypeAlias +from collections.abc import Callable, Coroutine +from typing import TYPE_CHECKING, Protocol, TypeAlias if TYPE_CHECKING: from redux import ReducerType diff --git a/ubo_app/services/000-sound/audio_manager.py b/ubo_app/services/000-sound/audio_manager.py index da2b1722..ef1479fc 100644 --- a/ubo_app/services/000-sound/audio_manager.py +++ b/ubo_app/services/000-sound/audio_manager.py @@ -59,25 +59,31 @@ async def initialize_audio() -> None: sink.proplist['alsa.card'], ) == str(self.cardindex): pulse.sink_default_set(sink) - break + return + logger.error('No audio card found') except pulsectl.PulseError: logger.exception('Not able to connect to pulseaudio') except StopIteration: logger.exception('No audio card found') - process = await asyncio.create_subprocess_exec( - '/usr/bin/env', - 'pulseaudio', - '--kill', - ) - await process.wait() - process = await asyncio.create_subprocess_exec( - '/usr/bin/env', - 'pulseaudio', - '--start', - ) - await process.wait() + except OSError: + logger.exception('Error while setting default sink') + logger.info('Restarting pulseaudio') + process = await asyncio.create_subprocess_exec( + '/usr/bin/env', + 'pulseaudio', + '--kill', + ) + await process.wait() + process = await asyncio.create_subprocess_exec( + '/usr/bin/env', + 'pulseaudio', + '--start', + ) + await process.wait() - await asyncio.sleep(5) + await asyncio.sleep(5) + else: + break create_task(initialize_audio()) @@ -85,7 +91,7 @@ def find_respeaker_index(self: AudioManager) -> int: """Find the index of the ReSpeaker device.""" for index in range(self.pyaudio.get_device_count()): info = self.pyaudio.get_device_info_by_index(index) - if not isinstance(info['name'], (int, float)) and 'wm8960' in info['name']: + if not isinstance(info['name'], int | float) and 'wm8960' in info['name']: logger.debug('ReSpeaker found at index', extra={'index': index}) logger.debug('Device Info', extra={'info': info}) return index diff --git a/ubo_app/services/020-keypad/setup.py b/ubo_app/services/020-keypad/setup.py index 31bc7ed9..e4369123 100644 --- a/ubo_app/services/020-keypad/setup.py +++ b/ubo_app/services/020-keypad/setup.py @@ -25,8 +25,7 @@ ButtonStatus = Literal['pressed', 'released'] -class KeypadError(Exception): - ... +class KeypadError(Exception): ... class ButtonName(StrEnum): diff --git a/ubo_app/services/030-ethernet/ethernet_manager.py b/ubo_app/services/030-ethernet/ethernet_manager.py index 86aa46b6..e3d92565 100644 --- a/ubo_app/services/030-ethernet/ethernet_manager.py +++ b/ubo_app/services/030-ethernet/ethernet_manager.py @@ -4,12 +4,13 @@ import asyncio from threading import current_thread -from typing import TYPE_CHECKING, Any, Coroutine, TypeVar +from typing import TYPE_CHECKING, Any, TypeVar from ubo_app.store.services.ethernet import GlobalEthernetState if TYPE_CHECKING: from asyncio.tasks import _FutureLike + from collections.abc import Coroutine T = TypeVar('T') diff --git a/ubo_app/services/030-ip/setup.py b/ubo_app/services/030-ip/setup.py index 6ce20c64..9537788d 100644 --- a/ubo_app/services/030-ip/setup.py +++ b/ubo_app/services/030-ip/setup.py @@ -4,7 +4,7 @@ import asyncio import socket from collections import defaultdict -from typing import Sequence +from typing import TYPE_CHECKING import psutil from constants import INTERNET_STATE_ICON_ID, INTERNET_STATE_ICON_PRIORITY @@ -20,6 +20,9 @@ ) from ubo_app.store.status_icons import StatusIconsRegisterAction +if TYPE_CHECKING: + from collections.abc import Sequence + @autorun(lambda state: state.ip.interfaces) def get_ip_addresses(interfaces: Sequence[IpNetworkInterface]) -> list[SubMenuItem]: diff --git a/ubo_app/services/030-wifi/pages/create_wireless_connection.py b/ubo_app/services/030-wifi/pages/create_wireless_connection.py index fa77ce28..0abc5906 100644 --- a/ubo_app/services/030-wifi/pages/create_wireless_connection.py +++ b/ubo_app/services/030-wifi/pages/create_wireless_connection.py @@ -3,7 +3,7 @@ import pathlib from distutils.util import strtobool -from typing import Sequence, cast +from typing import TYPE_CHECKING, cast from kivy.clock import mainthread from kivy.lang.builder import Builder @@ -26,6 +26,9 @@ from ubo_app.utils.async_ import create_task from ubo_app.utils.qrcode import qrcode_input +if TYPE_CHECKING: + from collections.abc import Sequence + # Regular expression pattern # WIFI:S:;T:;P:;H:;; BARCODE_PATTERN = ( diff --git a/ubo_app/services/030-wifi/pages/main.py b/ubo_app/services/030-wifi/pages/main.py index 7025f681..461722d9 100644 --- a/ubo_app/services/030-wifi/pages/main.py +++ b/ubo_app/services/030-wifi/pages/main.py @@ -1,7 +1,7 @@ # ruff: noqa: D100, D101, D102, D103, D104, D105, D107, N999 from __future__ import annotations -from typing import Any, Sequence +from typing import TYPE_CHECKING, Any from constants import get_signal_icon from debouncer import DebounceOptions, debounce @@ -32,6 +32,9 @@ from .create_wireless_connection import CreateWirelessConnectionPage +if TYPE_CHECKING: + from collections.abc import Sequence + class WiFiConnectionPage(PromptWidget): ssid: str diff --git a/ubo_app/services/030-wifi/wifi_manager.py b/ubo_app/services/030-wifi/wifi_manager.py index 87a058ba..171229f4 100644 --- a/ubo_app/services/030-wifi/wifi_manager.py +++ b/ubo_app/services/030-wifi/wifi_manager.py @@ -5,7 +5,7 @@ import asyncio import contextlib import uuid -from typing import TYPE_CHECKING, Any, Coroutine, TypeVar, cast +from typing import TYPE_CHECKING, Any, TypeVar, cast from debouncer import DebounceOptions, debounce from ubo_gui.constants import DANGER_COLOR @@ -27,6 +27,7 @@ if TYPE_CHECKING: from asyncio.tasks import _FutureLike + from collections.abc import Coroutine RETRIES = 3 diff --git a/ubo_app/services/040-rgb-ring/rgb_ring_client.py b/ubo_app/services/040-rgb-ring/rgb_ring_client.py index d7d2ee2e..dddad0b7 100644 --- a/ubo_app/services/040-rgb-ring/rgb_ring_client.py +++ b/ubo_app/services/040-rgb-ring/rgb_ring_client.py @@ -1,13 +1,16 @@ # ruff: noqa: D100, D101, D102, D103, D104, D105, D107 from __future__ import annotations -from typing import Sequence +from typing import TYPE_CHECKING from ubo_app.logging import logger from ubo_app.store import dispatch from ubo_app.store.services.rgb_ring import RgbRingSetIsConnectedAction from ubo_app.utils.server import send_command +if TYPE_CHECKING: + from collections.abc import Sequence + class RgbRingClient: """The instances of this class send commands to the LED manager. diff --git a/ubo_app/services/040-sensors/reducer.py b/ubo_app/services/040-sensors/reducer.py index 1a5d877d..f698ac5f 100644 --- a/ubo_app/services/040-sensors/reducer.py +++ b/ubo_app/services/040-sensors/reducer.py @@ -1,4 +1,5 @@ """Sensors reducer.""" + from __future__ import annotations from dataclasses import replace diff --git a/ubo_app/services/040-sensors/setup.py b/ubo_app/services/040-sensors/setup.py index 1cd4c7ac..e43ac010 100644 --- a/ubo_app/services/040-sensors/setup.py +++ b/ubo_app/services/040-sensors/setup.py @@ -2,7 +2,7 @@ from __future__ import annotations -from datetime import datetime, timezone +from datetime import UTC, datetime from ubo_app.store import dispatch from ubo_app.store.services.sensors import Sensor, SensorsReportReadingAction @@ -23,12 +23,12 @@ def read_sensors(_: float | None = None) -> None: SensorsReportReadingAction( sensor=Sensor.TEMPERATURE, reading=temperature, - timestamp=datetime.now(tz=timezone.utc), + timestamp=datetime.now(tz=UTC), ), SensorsReportReadingAction( sensor=Sensor.LIGHT, reading=light, - timestamp=datetime.now(tz=timezone.utc), + timestamp=datetime.now(tz=UTC), ), ) diff --git a/ubo_app/services/050-lightdm/setup.py b/ubo_app/services/050-lightdm/setup.py index c3414c75..c5ec0e80 100644 --- a/ubo_app/services/050-lightdm/setup.py +++ b/ubo_app/services/050-lightdm/setup.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from ubo_gui.menu.types import ActionItem, HeadlessMenu, Item, Menu @@ -18,6 +18,8 @@ from ubo_app.utils.server import send_command if TYPE_CHECKING: + from collections.abc import Sequence + from ubo_app.store.services.lightdm import LightDMState diff --git a/ubo_app/services/050-ssh/setup.py b/ubo_app/services/050-ssh/setup.py index 5cc2ab0e..a7e51a4c 100644 --- a/ubo_app/services/050-ssh/setup.py +++ b/ubo_app/services/050-ssh/setup.py @@ -3,7 +3,7 @@ from __future__ import annotations import asyncio -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from ubo_gui.menu.types import ( ActionItem, @@ -30,6 +30,8 @@ from ubo_app.utils.server import send_command if TYPE_CHECKING: + from collections.abc import Sequence + from ubo_app.store.services.ssh import SSHState @@ -208,7 +210,7 @@ def ssh_title(_: SSHState) -> str: async def check_is_ssh_active() -> None: """Check if the SSH service is active.""" - if await is_unit_active('sshd'): + if await is_unit_active('ssh'): dispatch(SSHUpdateStateAction(is_enabled=True)) else: dispatch(SSHUpdateStateAction(is_enabled=False)) @@ -216,7 +218,7 @@ async def check_is_ssh_active() -> None: async def check_is_ssh_enabled() -> None: """Check if the SSH service is enabled.""" - if await is_unit_enabled('sshd'): + if await is_unit_enabled('ssh'): dispatch(SSHUpdateStateAction(is_enabled=True)) else: dispatch(SSHUpdateStateAction(is_enabled=False)) diff --git a/ubo_app/services/080-docker/image.py b/ubo_app/services/080-docker/image.py index 86a55ab8..7ae0eab3 100644 --- a/ubo_app/services/080-docker/image.py +++ b/ubo_app/services/080-docker/image.py @@ -5,7 +5,7 @@ import contextlib import pathlib from asyncio import iscoroutine -from typing import Any, Callable, Coroutine, Mapping, cast, overload +from typing import TYPE_CHECKING, Any, cast, overload import docker import docker.errors @@ -33,6 +33,9 @@ ) from ubo_app.utils.async_ import create_task, run_in_executor +if TYPE_CHECKING: + from collections.abc import Callable, Coroutine, Mapping + def find_container(client: docker.DockerClient, *, image: str) -> Container | None: """Find a container.""" diff --git a/ubo_app/services/080-docker/reducer.py b/ubo_app/services/080-docker/reducer.py index 922364f6..5ee33820 100644 --- a/ubo_app/services/080-docker/reducer.py +++ b/ubo_app/services/080-docker/reducer.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import field, replace -from typing import Any, Callable, Coroutine +from typing import TYPE_CHECKING, Any from immutable import Immutable from redux import ( @@ -31,6 +31,9 @@ from ubo_app.store.services.ip import IpUpdateAction from ubo_app.utils.qrcode import qrcode_input +if TYPE_CHECKING: + from collections.abc import Callable, Coroutine + Action = InitAction | DockerAction diff --git a/ubo_app/services/080-docker/setup.py b/ubo_app/services/080-docker/setup.py index a66dff49..3bb37dec 100644 --- a/ubo_app/services/080-docker/setup.py +++ b/ubo_app/services/080-docker/setup.py @@ -6,7 +6,7 @@ import contextlib from dataclasses import fields from pathlib import Path -from typing import Callable +from typing import TYPE_CHECKING import docker import docker.errors @@ -26,6 +26,9 @@ from ubo_app.utils.monitor_unit import monitor_unit from ubo_app.utils.server import send_command +if TYPE_CHECKING: + from collections.abc import Callable + def install_docker() -> None: """Install Docker.""" diff --git a/ubo_app/side_effects.py b/ubo_app/side_effects.py index 7d46ae6e..d626d045 100644 --- a/ubo_app/side_effects.py +++ b/ubo_app/side_effects.py @@ -5,7 +5,7 @@ import atexit import subprocess import weakref -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from debouncer import DebounceOptions, debounce from kivy.clock import mainthread @@ -32,6 +32,8 @@ ) if TYPE_CHECKING: + from collections.abc import Sequence + from ubo_app.menu import MenuApp diff --git a/ubo_app/store/__init__.py b/ubo_app/store/__init__.py index 254b0d75..300bda7c 100644 --- a/ubo_app/store/__init__.py +++ b/ubo_app/store/__init__.py @@ -5,7 +5,7 @@ from dataclasses import replace from pathlib import Path from threading import current_thread, main_thread -from typing import TYPE_CHECKING, Callable, Coroutine +from typing import TYPE_CHECKING from redux import ( BaseCombineReducerState, @@ -37,6 +37,8 @@ from ubo_app.store.update_manager.reducer import reducer as update_manager_reducer if TYPE_CHECKING: + from collections.abc import Callable, Coroutine + from redux.basic_types import SnapshotAtom, TaskCreatorCallback assert current_thread() is main_thread(), 'Store should be created in the main thread' # noqa: S101 diff --git a/ubo_app/store/main/__init__.py b/ubo_app/store/main/__init__.py index 50e6ea62..9a6ced39 100644 --- a/ubo_app/store/main/__init__.py +++ b/ubo_app/store/main/__init__.py @@ -2,7 +2,7 @@ from __future__ import annotations from dataclasses import field -from typing import TYPE_CHECKING, Sequence +from typing import TYPE_CHECKING from immutable import Immutable from redux import BaseAction, BaseEvent, FinishAction, InitAction @@ -11,7 +11,9 @@ from ubo_app.store.status_icons import StatusIconsAction if TYPE_CHECKING: - from typing_extensions import TypeAlias + from collections.abc import Sequence + from typing import TypeAlias + from ubo_gui.menu.types import Item, Menu diff --git a/ubo_app/store/main/_menus.py b/ubo_app/store/main/_menus.py index 4b186ca7..d078a42d 100644 --- a/ubo_app/store/main/_menus.py +++ b/ubo_app/store/main/_menus.py @@ -1,7 +1,7 @@ from __future__ import annotations -from datetime import datetime, timezone -from typing import TYPE_CHECKING, Sequence +from datetime import UTC, datetime +from typing import TYPE_CHECKING from redux import AutorunOptions from ubo_gui.menu.types import ( @@ -19,6 +19,8 @@ from ubo_app.store.update_manager.utils import CURRENT_VERSION, about_menu_items if TYPE_CHECKING: + from collections.abc import Sequence + from ubo_gui.menu.types import Item @@ -112,7 +114,7 @@ def on_dismiss(self: NotificationWrapper) -> None: ) for index, notification in enumerate(notifications) if notification.expiry_date is None - or notification.expiry_date > datetime.now(tz=timezone.utc) + or notification.expiry_date > datetime.now(tz=UTC) ] diff --git a/ubo_app/store/main/reducer.py b/ubo_app/store/main/reducer.py index 82c0dfac..45cc6c2a 100644 --- a/ubo_app/store/main/reducer.py +++ b/ubo_app/store/main/reducer.py @@ -1,8 +1,9 @@ # ruff: noqa: D100, D101, D102, D103, D104, D107 from __future__ import annotations +from collections.abc import Sequence from dataclasses import replace -from typing import Sequence, cast +from typing import cast from redux import ( CompleteReducerResult, diff --git a/ubo_app/store/services/docker.py b/ubo_app/store/services/docker.py index 6781034e..b5d92538 100644 --- a/ubo_app/store/services/docker.py +++ b/ubo_app/store/services/docker.py @@ -1,4 +1,5 @@ """Docker store types.""" + from __future__ import annotations from dataclasses import field diff --git a/ubo_app/store/services/ip.py b/ubo_app/store/services/ip.py index 7028fe27..ea1411d1 100644 --- a/ubo_app/store/services/ip.py +++ b/ubo_app/store/services/ip.py @@ -1,18 +1,19 @@ # ruff: noqa: D100, D101, D102, D103, D104, D107 from __future__ import annotations -from typing import Sequence +from typing import TYPE_CHECKING from immutable import Immutable from redux import BaseAction, BaseEvent +if TYPE_CHECKING: + from collections.abc import Sequence -class IpAction(BaseAction): - ... +class IpAction(BaseAction): ... -class IpEvent(BaseEvent): - ... + +class IpEvent(BaseEvent): ... class IpUpdateRequestAction(IpAction): @@ -23,8 +24,7 @@ class IpUpdateAction(IpAction): interfaces: Sequence[IpNetworkInterface] -class IpUpdateRequestEvent(IpEvent): - ... +class IpUpdateRequestEvent(IpEvent): ... class IpNetworkInterface(Immutable): diff --git a/ubo_app/store/services/keypad.py b/ubo_app/store/services/keypad.py index d3b3730e..474f5293 100644 --- a/ubo_app/store/services/keypad.py +++ b/ubo_app/store/services/keypad.py @@ -20,21 +20,17 @@ class KeypadAction(BaseAction): key: Key -class KeypadKeyUpAction(KeypadAction): - ... +class KeypadKeyUpAction(KeypadAction): ... -class KeypadKeyDownAction(KeypadAction): - ... +class KeypadKeyDownAction(KeypadAction): ... -class KeypadKeyPressAction(KeypadAction): - ... +class KeypadKeyPressAction(KeypadAction): ... class KeypadEvent(BaseEvent): key: Key -class KeypadKeyPressEvent(KeypadEvent): - ... +class KeypadKeyPressEvent(KeypadEvent): ... diff --git a/ubo_app/store/services/notifications.py b/ubo_app/store/services/notifications.py index 3f9815f4..49c0337f 100644 --- a/ubo_app/store/services/notifications.py +++ b/ubo_app/store/services/notifications.py @@ -3,14 +3,17 @@ import sys from dataclasses import field -from datetime import datetime, timezone +from datetime import UTC, datetime from enum import StrEnum, auto -from typing import Sequence +from typing import TYPE_CHECKING from uuid import uuid4 from immutable import Immutable from redux import BaseAction, BaseEvent +if TYPE_CHECKING: + from collections.abc import Sequence + class Importance(StrEnum): CRITICAL = auto() @@ -74,7 +77,7 @@ class Notification(Immutable): content: str importance: Importance = Importance.LOW chime: Chime = Chime.DONE - timestamp: datetime = field(default_factory=lambda: datetime.now(tz=timezone.utc)) + timestamp: datetime = field(default_factory=lambda: datetime.now(tz=UTC)) is_read: bool = False sender: str | None = None actions: list[BaseAction | BaseEvent] = field(default_factory=list) diff --git a/ubo_app/store/services/rgb_ring.py b/ubo_app/store/services/rgb_ring.py index 108509bb..19bb4834 100644 --- a/ubo_app/store/services/rgb_ring.py +++ b/ubo_app/store/services/rgb_ring.py @@ -12,12 +12,10 @@ ) -class RgbRingAction(BaseAction): - ... +class RgbRingAction(BaseAction): ... -class RgbRingEvent(BaseEvent): - ... +class RgbRingEvent(BaseEvent): ... class RgbRingSetIsConnectedAction(RgbRingAction): @@ -28,8 +26,7 @@ class RgbRingSetIsBusyAction(RgbRingAction): is_busy: bool | None = None -class RgbRingCommandAction(RgbRingAction): - ... +class RgbRingCommandAction(RgbRingAction): ... class RgbRingWaitableCommandAction(RgbRingCommandAction): @@ -44,24 +41,21 @@ class RgbRingSetEnabledAction(RgbRingCommandAction): enabled: bool = True -class RgbRingSetAllAction(RgbRingColorfulCommandAction): - ... +class RgbRingSetAllAction(RgbRingColorfulCommandAction): ... class RgbRingSetBrightnessAction(RgbRingCommandAction): brightness: float = 0.5 -class RgbRingBlankAction(RgbRingCommandAction): - ... +class RgbRingBlankAction(RgbRingCommandAction): ... class RgbRingRainbowAction(RgbRingWaitableCommandAction): rounds: int -class RgbRingProgressWheelStepAction(RgbRingColorfulCommandAction): - ... +class RgbRingProgressWheelStepAction(RgbRingColorfulCommandAction): ... class RgbRingPulseAction(RgbRingWaitableCommandAction, RgbRingColorfulCommandAction): diff --git a/ubo_app/store/services/sensors.py b/ubo_app/store/services/sensors.py index 9b7f313e..96fb0c94 100644 --- a/ubo_app/store/services/sensors.py +++ b/ubo_app/store/services/sensors.py @@ -1,8 +1,9 @@ # ruff: noqa: D100, D101, D102, D103, D104, D107 from __future__ import annotations +from collections.abc import Sequence from enum import StrEnum, auto -from typing import TYPE_CHECKING, Generic, Sequence, TypeVar +from typing import TYPE_CHECKING, Generic, TypeVar from immutable import Immutable from redux import BaseAction diff --git a/ubo_app/store/services/sound.py b/ubo_app/store/services/sound.py index 0fb8e2f4..7dfe2d6f 100644 --- a/ubo_app/store/services/sound.py +++ b/ubo_app/store/services/sound.py @@ -12,8 +12,7 @@ class SoundDevice(StrEnum): OUTPUT = 'Output' -class SoundAction(BaseAction): - ... +class SoundAction(BaseAction): ... class SoundSetVolumeAction(SoundAction): @@ -39,8 +38,7 @@ class SoundPlayChimeAction(SoundAction): name: str -class SoundEvent(BaseEvent): - ... +class SoundEvent(BaseEvent): ... class SoundPlayChimeEvent(SoundEvent): diff --git a/ubo_app/store/services/wifi.py b/ubo_app/store/services/wifi.py index 68238dfd..9059d4b3 100644 --- a/ubo_app/store/services/wifi.py +++ b/ubo_app/store/services/wifi.py @@ -2,11 +2,14 @@ from __future__ import annotations from enum import StrEnum -from typing import Sequence +from typing import TYPE_CHECKING from immutable import Immutable from redux import BaseAction, BaseEvent +if TYPE_CHECKING: + from collections.abc import Sequence + class WiFiType(StrEnum): WEP = 'WEP' diff --git a/ubo_app/store/status_icons/__init__.py b/ubo_app/store/status_icons/__init__.py index ea1f511b..42faff69 100644 --- a/ubo_app/store/status_icons/__init__.py +++ b/ubo_app/store/status_icons/__init__.py @@ -1,11 +1,14 @@ # ruff: noqa: D100, D101, D102, D103, D104, D107 from __future__ import annotations -from typing import Sequence +from typing import TYPE_CHECKING from immutable import Immutable from redux import BaseAction +if TYPE_CHECKING: + from collections.abc import Sequence + class IconState(Immutable): symbol: str @@ -18,8 +21,7 @@ class StatusIconsState(Immutable): icons: Sequence[IconState] -class StatusIconsAction(BaseAction): - ... +class StatusIconsAction(BaseAction): ... class StatusIconsRegisterAction(StatusIconsAction): diff --git a/ubo_app/store/update_manager/__init__.py b/ubo_app/store/update_manager/__init__.py index 0b8af7b4..c374cca3 100644 --- a/ubo_app/store/update_manager/__init__.py +++ b/ubo_app/store/update_manager/__init__.py @@ -9,8 +9,7 @@ UPDATE_MANAGER_NOTIFICATION_ID = 'ubo:update_manager' -class UpdateManagerAction(BaseAction): - ... +class UpdateManagerAction(BaseAction): ... class UpdateManagerSetVersionsAction(UpdateManagerAction): @@ -23,16 +22,13 @@ class UpdateManagerSetStatusAction(UpdateManagerAction): status: UpdateStatus -class UpdateManagerEvent(BaseEvent): - ... +class UpdateManagerEvent(BaseEvent): ... -class UpdateManagerCheckEvent(UpdateManagerEvent): - ... +class UpdateManagerCheckEvent(UpdateManagerEvent): ... -class UpdateManagerUpdateEvent(UpdateManagerEvent): - ... +class UpdateManagerUpdateEvent(UpdateManagerEvent): ... class UpdateStatus(StrEnum): diff --git a/ubo_app/store/update_manager/utils.py b/ubo_app/store/update_manager/utils.py index e2e7850a..5fb15299 100644 --- a/ubo_app/store/update_manager/utils.py +++ b/ubo_app/store/update_manager/utils.py @@ -38,10 +38,13 @@ async def check_version() -> None: # Check PyPI server for the latest version try: - async with aiohttp.ClientSession() as session, session.get( - 'https://pypi.org/pypi/ubo-app/json', - timeout=5, - ) as response: + async with ( + aiohttp.ClientSession() as session, + session.get( + 'https://pypi.org/pypi/ubo-app/json', + timeout=5, + ) as response, + ): if response.status != requests.codes.ok: logger.error('Failed to check for updates') return diff --git a/ubo_app/system/system_manager/clear_all_temporary_accounts.sh b/ubo_app/system/system_manager/clear_all_temporary_accounts.sh index 4c8616d0..bce26b2f 100755 --- a/ubo_app/system/system_manager/clear_all_temporary_accounts.sh +++ b/ubo_app/system/system_manager/clear_all_temporary_accounts.sh @@ -21,4 +21,4 @@ done # Disable password authentication sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config -systemctl restart sshd +systemctl restart ssh diff --git a/ubo_app/system/system_manager/create_temporary_ssh_account.sh b/ubo_app/system/system_manager/create_temporary_ssh_account.sh index 384884c5..828905fa 100755 --- a/ubo_app/system/system_manager/create_temporary_ssh_account.sh +++ b/ubo_app/system/system_manager/create_temporary_ssh_account.sh @@ -37,4 +37,4 @@ echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} # Allow password authentication sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config -systemctl restart sshd +systemctl restart ssh diff --git a/ubo_app/system/system_manager/led.py b/ubo_app/system/system_manager/led.py index f438b03a..e00b87a6 100644 --- a/ubo_app/system/system_manager/led.py +++ b/ubo_app/system/system_manager/led.py @@ -4,7 +4,7 @@ import logging import time from threading import Thread -from typing import TYPE_CHECKING, Sequence, cast +from typing import TYPE_CHECKING, cast import board import neopixel @@ -14,6 +14,8 @@ from ubo_app.logging import add_file_handler, add_stdout_handler, get_logger if TYPE_CHECKING: + from collections.abc import Sequence + from ubo_app.store.services.rgb_ring import Color BRIGHTNESS = 1.0 diff --git a/ubo_app/system/system_manager/service_manager.py b/ubo_app/system/system_manager/service_manager.py index 4438aad9..c90979f8 100644 --- a/ubo_app/system/system_manager/service_manager.py +++ b/ubo_app/system/system_manager/service_manager.py @@ -26,22 +26,22 @@ def ssh_handler(command: str) -> str | None: ) if command == 'start': subprocess.run( - ['/usr/bin/env', 'systemctl', 'start', 'sshd'], # noqa: S603 + ['/usr/bin/env', 'systemctl', 'start', 'ssh'], # noqa: S603 check=True, ) if command == 'stop': subprocess.run( - ['/usr/bin/env', 'systemctl', 'stop', 'sshd'], # noqa: S603 + ['/usr/bin/env', 'systemctl', 'stop', 'ssh'], # noqa: S603 check=True, ) if command == 'enable': subprocess.run( - ['/usr/bin/env', 'systemctl', 'enable', 'sshd'], # noqa: S603 + ['/usr/bin/env', 'systemctl', 'enable', 'ssh'], # noqa: S603 check=True, ) if command == 'disable': subprocess.run( - ['/usr/bin/env', 'systemctl', 'disable', 'sshd'], # noqa: S603 + ['/usr/bin/env', 'systemctl', 'disable', 'ssh'], # noqa: S603 check=True, ) msg = f'Invalid ssh command "{command}"' diff --git a/ubo_app/utils/async_.py b/ubo_app/utils/async_.py index abcb1421..33e8a181 100644 --- a/ubo_app/utils/async_.py +++ b/ubo_app/utils/async_.py @@ -2,12 +2,13 @@ from __future__ import annotations from threading import current_thread -from typing import TYPE_CHECKING, Awaitable, Callable, TypeVarTuple, Unpack +from typing import TYPE_CHECKING, TypeVarTuple, Unpack from typing_extensions import TypeVar if TYPE_CHECKING: from asyncio import Future, Handle + from collections.abc import Awaitable, Callable from redux.basic_types import TaskCreatorCallback diff --git a/ubo_app/utils/fake.py b/ubo_app/utils/fake.py index 68e144e5..b65ae8fe 100644 --- a/ubo_app/utils/fake.py +++ b/ubo_app/utils/fake.py @@ -2,10 +2,13 @@ from __future__ import annotations from types import ModuleType -from typing import Any, Generator, Iterator, Self, cast +from typing import TYPE_CHECKING, Any, Self, cast from ubo_app.logging import logger +if TYPE_CHECKING: + from collections.abc import Generator, Iterator + class Fake(ModuleType): def __init__( diff --git a/ubo_app/utils/garbage_collection.py b/ubo_app/utils/garbage_collection.py index 9d3b850b..258fcfb6 100644 --- a/ubo_app/utils/garbage_collection.py +++ b/ubo_app/utils/garbage_collection.py @@ -6,12 +6,13 @@ import contextlib import gc from sys import stdout -from typing import TYPE_CHECKING, Callable +from typing import TYPE_CHECKING from redux.main import inspect if TYPE_CHECKING: import weakref + from collections.abc import Callable SHORT_PRINT_LENGTH = 60 diff --git a/ubo_app/utils/loop.py b/ubo_app/utils/loop.py index 06ef3ee8..2c3995cf 100644 --- a/ubo_app/utils/loop.py +++ b/ubo_app/utils/loop.py @@ -4,13 +4,14 @@ import asyncio import contextlib import threading -from typing import TYPE_CHECKING, Callable, Coroutine, TypeVarTuple, Unpack +from typing import TYPE_CHECKING, TypeVarTuple, Unpack from typing_extensions import TypeVar if TYPE_CHECKING: from asyncio import Future, Handle from asyncio.tasks import Task + from collections.abc import Callable, Coroutine from redux.basic_types import TaskCreatorCallback diff --git a/ubo_app/utils/monitor_unit.py b/ubo_app/utils/monitor_unit.py index 87e772ac..8cc2a3b8 100644 --- a/ubo_app/utils/monitor_unit.py +++ b/ubo_app/utils/monitor_unit.py @@ -4,12 +4,15 @@ import asyncio import subprocess -from typing import Callable +from typing import TYPE_CHECKING from sdbus import DbusInterfaceCommonAsync, dbus_property_async from ubo_app.utils.bus_provider import get_system_bus +if TYPE_CHECKING: + from collections.abc import Callable + class SystemdUnitInterface( # pyright: ignore [reportGeneralTypeIssues] DbusInterfaceCommonAsync, diff --git a/ubo_app/utils/qrcode.py b/ubo_app/utils/qrcode.py index 6f83d8fa..f6d0a18e 100644 --- a/ubo_app/utils/qrcode.py +++ b/ubo_app/utils/qrcode.py @@ -3,10 +3,10 @@ from __future__ import annotations import asyncio +import datetime import uuid from asyncio import Future -from datetime import datetime, timezone -from typing import Callable, TypeAlias, overload +from typing import TYPE_CHECKING, TypeAlias, overload from typing_extensions import TypeVar @@ -24,6 +24,9 @@ ) from ubo_app.store.services.rgb_ring import RgbRingBlinkAction +if TYPE_CHECKING: + from collections.abc import Callable + QrCodeGroupDict: TypeAlias = dict[str, str | None] | None @@ -66,7 +69,7 @@ async def qrcode_input( content=prompt, display_type=NotificationDisplayType.STICKY, is_read=True, - expiry_date=datetime.now(tz=timezone.utc), + expiry_date=datetime.datetime.now(tz=datetime.UTC), ) def clear_notification(event: NotificationsClearEvent) -> None: