chore: clear typehinting errors

This commit is contained in:
aclist committed 2026-05-15 19:53:00 +09:00
1 parent cacfab35bf
commit 2d265c4b9b
19 files changed
+74 -44

No files matched your search

+9 -4
View File
@@ -5,22 +5,26 @@ from typing import Self
from dzgui.util.strings import dialog_error, dialog_header
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402
class EarlyAlertDialog(Gtk.MessageDialog):
def __init__(self, string: str) -> None:
super().__init__(
title=dialog_header,
text=dialog_error,
transient_for=None,
buttons=Gtk.ButtonsType.OK
buttons=Gtk.ButtonsType.OK,
)
msg = textwrap.fill(string, 50)
self.format_secondary_text(msg)
self.action_area.set_margin_bottom(20)
aa = self.get_action_area()
aa.set_margin_bottom(20)
# self.action_area.set_margin_bottom(20)
self.outer = self.get_content_area()
self.outer.set_margin_start(30)
self.outer.set_margin_end(30)
@@ -28,7 +32,8 @@ class EarlyAlertDialog(Gtk.MessageDialog):
self.set_default_size(250, 100)
abort = self.get_widget_for_response(Gtk.ResponseType.OK)
abort.set_label("Exit")
if abort is not None and hasattr(abort, "set_label"):
abort.set_label("Exit")
self.connect("response", self._on_response)
self.run()
@@ -41,10 +46,10 @@ class EarlyAlertDialog(Gtk.MessageDialog):
case Gtk.ResponseType.CANCEL:
return
class EarlyIgnoreDialog(EarlyAlertDialog):
def __init__(self, string: str) -> None:
super().__init__(string=string)
# TODO: reverse order
self.add_button("Ignore", Gtk.ResponseType.CANCEL)
+3 -1
View File
@@ -205,7 +205,9 @@ class ExceptionDialog(GenericDialog):
self.add_button("OK", Gtk.ResponseType.OK)
self.show_all()
self.action_area.get_children()[1].grab_focus()
self.ok = self.get_widget_for_response(Gtk.ResponseType.OK)
if self.ok is not None:
self.ok.grab_focus()
self.connect("response", self._on_response)
def get_trace(self) -> str:
+18 -5
View File
@@ -1,6 +1,7 @@
from typing import Self, TYPE_CHECKING
from dzgui.const.constants import EXPAND, FILL
from dzgui.const.enum import ContextMenuGroup
from dzgui.model.model_factory import ModelFactory
from dzgui.util import css
from dzgui.util import strings
@@ -20,7 +21,13 @@ if TYPE_CHECKING:
class ServerDialog(GenericDialog):
def __init__(self, controller: "Controller", title: str, secondary: str) -> None:
def __init__(
self,
controller: "Controller",
title: str,
secondary: str,
menu: ContextMenuGroup | None,
) -> None:
super().__init__(
controller=controller,
text=title,
@@ -32,7 +39,7 @@ class ServerDialog(GenericDialog):
self.set_default_response(Gtk.ResponseType.OK)
self.set_size_request(800, 700)
self.view = TreeView(controller)
self.view = TreeView(controller, menu)
self.view.set_fixed_height_mode(True)
self.connect("response", self._on_response)
@@ -59,7 +66,7 @@ class ServerDialog(GenericDialog):
class ServerDetailsDialog(ServerDialog):
def __init__(self, controller: "Controller", details: "Details"):
name = controller.get_server_name()
super().__init__(controller, strings.server_details, name)
super().__init__(controller, strings.server_details, name, menu=None)
self.store = Gtk.ListStore(str, str, Pango.Weight)
self.view.connect("row-activated", self._on_row_activated)
@@ -116,10 +123,16 @@ class ServerDetailsDialog(ServerDialog):
class ServerModDialog(ServerDialog):
def __init__(self, controller: "Controller", mods: list[list[str]]):
def __init__(
self,
controller: "Controller",
mods: list[list[str]],
):
name = controller.get_server_name()
super().__init__(controller, server_mods.modlist, name)
super().__init__(
controller, server_mods.modlist, name, menu=ContextMenuGroup.SERVER_MOD
)
self.controller = controller
self.mod_store = ModelFactory().make_server_mod_store()