enable ASYNC, DTZ, YTT and EM lints

This commit is contained in:
Jörg Thalheim
2024-09-02 13:55:46 +02:00
parent d5440594be
commit 15ff74f7c2
98 changed files with 526 additions and 421 deletions

View File

@@ -29,7 +29,7 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
self.gtype = gtype
self.key_gen = key_gen
# From Python 3.7 onwards dictionaries are ordered by default
self._items: dict[K, V] = dict()
self._items: dict[K, V] = {}
##################################
# #
@@ -76,9 +76,11 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
)
key = self.key_gen(item)
if key in self._items:
raise ValueError("Key already exists in the dictionary")
msg = "Key already exists in the dictionary"
raise ValueError(msg)
if position < 0 or position > len(self._items):
raise IndexError("Index out of range")
msg = "Index out of range"
raise IndexError(msg)
# Temporary storage for items to be reinserted
temp_list = [(k, self._items[k]) for k in list(self.keys())[position:]]
@@ -91,7 +93,7 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
self._items[key] = item
# Reinsert the items
for i, (k, v) in enumerate(temp_list):
for _i, (k, v) in enumerate(temp_list):
self._items[k] = v
# Notify the model of the changes
@@ -100,7 +102,8 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
def insert_sorted(
self, item: V, compare_func: Callable[[V, V, Any], int], user_data: Any
) -> None:
raise NotImplementedError("insert_sorted is not implemented in GKVStore")
msg = "insert_sorted is not implemented in GKVStore"
raise NotImplementedError(msg)
def remove(self, position: int) -> None:
if position < 0 or position >= self.get_n_items():
@@ -114,10 +117,12 @@ class GKVStore(GObject.GObject, Gio.ListModel, Generic[K, V]):
self.items_changed(0, len(self._items), 0)
def sort(self, compare_func: Callable[[V, V, Any], int], user_data: Any) -> None:
raise NotImplementedError("sort is not implemented in GKVStore")
msg = "sort is not implemented in GKVStore"
raise NotImplementedError(msg)
def splice(self, position: int, n_removals: int, additions: list[V]) -> None:
raise NotImplementedError("splice is not implemented in GKVStore")
msg = "splice is not implemented in GKVStore"
raise NotImplementedError(msg)
##################################
# #

View File

@@ -350,9 +350,8 @@ class StatusNotifierImplementation(BaseImplementation):
)
if not registration_id:
raise GLib.Error(
f"Failed to register object with path {self._object_path}"
)
msg = f"Failed to register object with path {self._object_path}"
raise GLib.Error(msg)
self._registration_id = registration_id
@@ -582,9 +581,8 @@ class StatusNotifierImplementation(BaseImplementation):
except GLib.Error as error:
self.unload()
raise ImplUnavailableError(
f"StatusNotifier implementation not available: {error}"
) from error
msg = f"StatusNotifier implementation not available: {error}"
raise ImplUnavailableError(msg) from error
self.update_menu()

View File

@@ -1,3 +1,4 @@
import datetime
import logging
import multiprocessing as mp
import os
@@ -7,7 +8,6 @@ import time
import weakref
from collections.abc import Callable, Generator
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from typing import IO, ClassVar
@@ -181,7 +181,7 @@ class VMObject(GObject.Object):
def __start(self) -> None:
with self._create_machine() as machine:
# Start building VM
tstart = datetime.now()
tstart = datetime.datetime.now(tz=datetime.UTC)
log.info(f"Building VM {self.get_id()}")
log_dir = Path(str(self.log_dir.name))
@@ -219,7 +219,7 @@ class VMObject(GObject.Object):
# Wait for the build to finish then hide the progress bar
self.build_process.proc.join()
tend = datetime.now()
tend = datetime.datetime.now(tz=datetime.UTC)
log.info(f"VM {self.get_id()} build took {tend - tstart}s")
self.progress_bar.hide()
@@ -312,9 +312,9 @@ class VMObject(GObject.Object):
def __stop(self) -> None:
log.info(f"Stopping VM {self.get_id()}")
start_time = datetime.now()
start_time = datetime.datetime.now(tz=datetime.UTC)
while self.is_running():
diff = datetime.now() - start_time
diff = datetime.datetime.now(tz=datetime.UTC) - start_time
if diff.seconds > self.KILL_TIMEOUT:
log.error(
f"VM {self.get_id()} has not stopped after {self.KILL_TIMEOUT}s. Killing it"