chore: clear type annotation errors

This commit is contained in:
aclist 2026-06-11 12:10:37 +09:00
parent 8123893a90
commit 65fb07c8da
6 changed files with 15 additions and 17 deletions

View File

@ -48,7 +48,7 @@ def get_local_mods(workshop_path: Path) -> list[Path]:
mods = [file for file in workshop_path.iterdir() if file.is_dir()]
return mods
def is_mission(path: Path) -> None:
def is_mission(path: Path) -> bool:
# TODO: parse integrity of other files
file = path / "init.c"
return file.exists()

View File

@ -36,7 +36,6 @@ from gi.repository import Gtk, Gdk, GLib, GObject # noqa E402
logger = logging.getLogger(APP_NAME)
if TYPE_CHECKING:
from pathlib import Path
from dzgui.api.servers import Record
from dzgui.const.enum import ServerTab
from dzgui.managers.connection import Prerequisites

View File

@ -68,6 +68,8 @@ class ModManager:
def _on_mods_loaded(self) -> None:
self.treeview.set_model(self.store)
if self.store is None:
return
msg = self.format_mod_statusbar()
total_mods = len(self.store)
self.emitter.emit("mods_updated", msg, total_mods)
@ -124,6 +126,8 @@ class ModManager:
pass
def _on_mods_deleted(self, iters: list[Gtk.TreeIter]) -> None:
if self.store is None:
return
for _iter in iters:
self.store.remove(_iter)
remove_stale_signatures(self.prefs.paths.config, self.prefs.paths.version)

View File

@ -37,8 +37,9 @@ class OfflineManager:
return
is_valid = is_mission(folder)
if is_valid:
self.mission_folder = folder
self.emitter.emit("custom_mission_loaded", folder, is_valid)
# TODO: str
self.mission_folder = str(folder)
self.emitter.emit("custom_mission_loaded", str(folder), is_valid)
def get_custom_mods(self, local_mods: list[str]) -> None:
folder = self.open_folderpicker()

View File

@ -140,7 +140,7 @@ class BootDialog(Gtk.Dialog):
GLib.timeout_add(100, self.pulse_spinner)
def _on_keypress(self, Self, event: Gdk.EventKey) -> None:
def _on_keypress(self, widget: Self, event: Gdk.EventKey) -> None:
if event.keyval == Gdk.KEY_Escape:
self.exit_button.emit("clicked")

View File

@ -1,6 +1,6 @@
from __future__ import annotations
from pathlib import Path
from typing import Self, Sequence, TYPE_CHECKING
from typing import Self, Sequence, TYPE_CHECKING, Union
from dzgui.util import css
import dzgui.api.pefile as PeFile
@ -76,6 +76,7 @@ class FolderHBox(HBox):
return self.button
def set_label(self, label: str) -> None:
# TODO: strings
prefix = "Current folder: "
self.label.set_label(prefix + label)
@ -155,7 +156,7 @@ class ModFrame(HeadingFrame):
def pack(self, widget: Gtk.Widget) -> None:
self.vbox.pack_start(widget, expand=False, fill=False, padding=5)
def set_model(self, model: "FastInsertListStore") -> None:
def set_model(self, model: Union["FastInsertListStore", None]) -> None:
self.tree.set_model(model)
self.tree.mod_man.store = model
self.set_cursor()
@ -174,11 +175,6 @@ class ModFrame(HeadingFrame):
self.tree.set_cursor(path)
self.tree.get_selection().unselect_all()
#class LocalModFrame(ModFrame):
# def __init__(self, controller: "Controller", label: str) -> None:
# super().__init__(controller=controller, label=label)
class CustomModFrame(ModFrame):
def __init__(
@ -210,6 +206,7 @@ class CustomModFrame(ModFrame):
) -> None:
if len(store) == 0:
# TODO: abstract into single method
# TODO: strings
self.set_error("No valid mods found")
self.show_errors()
self.custom_hbox.hide_label()
@ -293,7 +290,7 @@ class OfflineLoader(Gtk.Box):
self.local_frame = ModFrame(self, controller, offline.local_frame)
self.custom_frame = CustomModFrame(self, controller, offline.custom_frame)
# TODO: suppress symlink column
# TODO: dynamically calculate new symlink hashes
self.custom_tree = OfflineModTreeView(controller)
self.mission_hbox = FolderHBox(offline.mission_button)
@ -366,13 +363,10 @@ class OfflineLoader(Gtk.Box):
self.controller.open_page(NotebookPage.MODS)
def _on_ok_clicked(self, button: Gtk.Button) -> None:
# TODO; block button access if no mods are selected
# TODO: consider hooking up to emitter and changing button state whenever mods are selected
# appid = self.radio_frame.get_appid()
# mission = self.mission_frame.get_mission()
# local_mods = self.local_frame.get_mods()
# custom_mods = self.custom_frame.get_mods()
# cf. api.mods._hash(uid, use_custom=True)
# offline_man.setup(appid, mission, local_mods, custom_mods)
# self.offline_man.setup(appid, mission, local_mods, custom_mods)
pass