enable ASYNC, DTZ, YTT and EM lints
This commit is contained in:
@@ -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)
|
||||
|
||||
##################################
|
||||
# #
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -30,7 +30,8 @@ class ToastOverlay:
|
||||
_instance: "None | ToastOverlay" = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
raise RuntimeError("Call use() instead")
|
||||
msg = "Call use() instead"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
@classmethod
|
||||
def use(cls: Any) -> "ToastOverlay":
|
||||
|
||||
@@ -55,7 +55,8 @@ class JoinList:
|
||||
|
||||
# Make sure the VMS class is used as a singleton
|
||||
def __init__(self) -> None:
|
||||
raise RuntimeError("Call use() instead")
|
||||
msg = "Call use() instead"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
@classmethod
|
||||
def use(cls: Any) -> "JoinList":
|
||||
|
||||
@@ -25,7 +25,8 @@ class ViewStack:
|
||||
|
||||
# Make sure the VMS class is used as a singleton
|
||||
def __init__(self) -> None:
|
||||
raise RuntimeError("Call use() instead")
|
||||
msg = "Call use() instead"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
@classmethod
|
||||
def use(cls: Any) -> "ViewStack":
|
||||
|
||||
@@ -44,7 +44,8 @@ class ClanStore:
|
||||
|
||||
# Make sure the VMS class is used as a singleton
|
||||
def __init__(self) -> None:
|
||||
raise RuntimeError("Call use() instead")
|
||||
msg = "Call use() instead"
|
||||
raise RuntimeError(msg)
|
||||
|
||||
@classmethod
|
||||
def use(cls: Any) -> "ClanStore":
|
||||
|
||||
@@ -258,14 +258,16 @@ class ClanList(Gtk.Box):
|
||||
def show_vm_build_logs(self, target: str) -> None:
|
||||
vm = ClanStore.use().set_logging_vm(target)
|
||||
if vm is None:
|
||||
raise ValueError(f"VM {target} not found")
|
||||
msg = f"VM {target} not found"
|
||||
raise ValueError(msg)
|
||||
|
||||
views = ViewStack.use().view
|
||||
# Reset the logs view
|
||||
logs: Logs = views.get_child_by_name("logs") # type: ignore
|
||||
|
||||
if logs is None:
|
||||
raise ValueError("Logs view not found")
|
||||
msg = "Logs view not found"
|
||||
raise ValueError(msg)
|
||||
|
||||
name = vm.machine.name if vm.machine else "Unknown"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user