chore: clear typehinting errors

This commit is contained in:
aclist committed 2026-05-12 15:58:09 +09:00
1 parent 2e5860650f
commit e52664cf9b
11 files changed
+35 -29

No files matched your search

+14 -14
View File
@@ -4,7 +4,7 @@ import struct
from dataclasses import dataclass from dataclasses import dataclass
from enum import Enum from enum import Enum
from pathlib import Path from pathlib import Path
from typing import BinaryIO, Union from typing import BinaryIO, Self, Union
from packaging.version import Version from packaging.version import Version
@@ -69,7 +69,7 @@ class i64:
class PackedData: class PackedData:
@classmethod @classmethod
def unpack(cls, data: BinaryIO): def unpack(cls, data: BinaryIO) -> Self:
r = [] r = []
for key, value in cls.__annotations__.items(): for key, value in cls.__annotations__.items():
if value is str: if value is str:
@@ -449,18 +449,18 @@ def get_app_path(folders_path: Path, appid: int) -> Path:
# TODO: tests # TODO: tests
def compare_versions(local: DayZVersion, remote: DayZVersion) -> VersionMatch: #def compare_versions(local: DayZVersion, remote: DayZVersion) -> VersionMatch:
local_str = Version(dayz_version_to_str(local)) # local_str = Version(dayz_version_to_str(local))
remote_str = Version(dayz_version_to_str(remote)) # remote_str = Version(dayz_version_to_str(remote))
#
if local_str == remote_str: # if local_str == remote_str:
return VersionMatch.SAME_VERSION # return VersionMatch.SAME_VERSION
#
if local_str < remote_str: # if local_str < remote_str:
return VersionMatch.LOCAL_OLDER # return VersionMatch.LOCAL_OLDER
#
if local_str > remote_str: # if local_str > remote_str:
return VersionMatch.LOCAL_NEWER # return VersionMatch.LOCAL_NEWER
def get_pretty_version(steam_path: Path, appid: int) -> str | None: def get_pretty_version(steam_path: Path, appid: int) -> str | None:
+1 -1
View File
@@ -464,7 +464,7 @@ def query_by_ip(addr: str) -> A2SInfo:
record = short_ip_to_record(addr) record = short_ip_to_record(addr)
return query_by_record(record, update_gameport=True) return query_by_record(record, update_gameport=True)
def query_by_id(server_id: int, key: str) -> dict[Any] | None: def query_by_id(server_id: int, key: str) -> A2SInfo:
""" """
Used with numeric Battlemetrics IDs Used with numeric Battlemetrics IDs
""" """
+2 -2
View File
@@ -89,7 +89,7 @@ def get_remote_signatures(mods: list[str]) -> list[tuple[str, str, int, int]]:
# TODO:: set config to name=user, use official server and no mods, # TODO:: set config to name=user, use official server and no mods,
# ensure that formatted string is identical to fixture with same hash # ensure that formatted string is identical to fixture with same hash
def connect(addr: str, appid: int, name: str, mods: list[str]) -> None: def connect(addr: str, appid: int, name: str, mods: list[str]) -> int:
concat = concat_mods(mods) concat = concat_mods(mods)
params = [ params = [
"steam", "steam",
@@ -121,7 +121,7 @@ def find_user_id(path: Path) -> str | None:
def vdf2json(path: Path) -> str: def vdf2json(path: Path) -> str:
def _istr(indent: int, string: str): def _istr(indent: int, string: str) -> str:
return (indent * " ") + string return (indent * " ") + string
jbuf = "{\n" jbuf = "{\n"
+2 -1
View File
@@ -1,6 +1,7 @@
import json import json
import shlex import shlex
from pathlib import Path from pathlib import Path
from typing import Any
""" """
@@ -34,7 +35,7 @@ def rc2json(file: Path) -> str:
lex = shlex.shlex(f.read()) lex = shlex.shlex(f.read())
lex.whitespace += "=" lex.whitespace += "="
keys = {} keys: dict[str, Any] = {}
ips: list[str] = [] ips: list[str] = []
toggles = ["auto_install", "fullscreen"] toggles = ["auto_install", "fullscreen"]
+2 -2
View File
@@ -95,8 +95,8 @@ class ConfigManager:
) )
return return
def get_start_tab(self) -> int: def get_start_tab(self) -> Any:
return self.lookup(Preferences.START_TAB) return int(self.lookup(Preferences.START_TAB))
def get_favorites(self) -> list[str]: def get_favorites(self) -> list[str]:
return list(self.lookup(Preferences.IP_LIST)) return list(self.lookup(Preferences.IP_LIST))
+4 -4
View File
@@ -74,7 +74,7 @@ class Prerequisites:
passworded: bool passworded: bool
dayz_running: bool dayz_running: bool
steam_proc: SteamProcess steam_proc: SteamProcess
mods: list[str] mods: list[list[str]]
foreground_cmd: str | None foreground_cmd: str | None
game_mode: bool game_mode: bool
@@ -90,7 +90,7 @@ class ConnectionManager:
self.workshop: Path self.workshop: Path
self.remote_mod_ids: list[str] = [] self.remote_mod_ids: list[str] = []
self.missing_mods: list[str, str, int, int] = [] self.missing_mods: list[tuple[str, str, int, int]] = []
@call_on_thread(dialog.querying) @call_on_thread(dialog.querying)
def connect_by_id(self, _id: int, key: str) -> None: def connect_by_id(self, _id: int, key: str) -> None:
@@ -206,7 +206,7 @@ class ConnectionManager:
mods = Servers.get_rules(record) mods = Servers.get_rules(record)
steam_path = self.controller.query_config(Preferences.DEFAULT) steam_path = self.controller.query_config(Preferences.DEFAULT)
local = get_local_mod_ids(steam_path) local = get_local_mod_ids(steam_path)
alpha_mods = [ alpha_mods: list[list[str]] = [
[ [
mod.name, mod.name,
str(mod.workshop_id), str(mod.workshop_id),
@@ -231,7 +231,7 @@ class ConnectionManager:
destroy_first=True, destroy_first=True,
) )
def _present_modlist_dialog(self, mods: list[str]) -> None: def _present_modlist_dialog(self, mods: list[list[str]]) -> None:
dialog = ServerModDialog(self.controller, mods) dialog = ServerModDialog(self.controller, mods)
dialog.run() dialog.run()
+4 -1
View File
@@ -12,6 +12,7 @@ from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa E402
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
from dzgui.views.base import Notebook from dzgui.views.base import Notebook
from dzgui.views.pages.servers import ServerNotebook
class Breadcrumbs(Gtk.Label): class Breadcrumbs(Gtk.Label):
@@ -30,10 +31,12 @@ class Breadcrumbs(Gtk.Label):
self, notebook: "Notebook", page: Gtk.Widget, index: int self, notebook: "Notebook", page: Gtk.Widget, index: int
) -> None: ) -> None:
label = notebook.get_tab_label_text(page) label = notebook.get_tab_label_text(page)
if label is None:
return
self.set_server_crumbs(label) self.set_server_crumbs(label)
def _on_notebook_page_changed( def _on_notebook_page_changed(
self, notebook: "Notebook", page: Gtk.Widget, index: int self, notebook: "Notebook", page: "ServerNotebook", index: int
) -> None: ) -> None:
enum = notebook.get_page_by_enum() enum = notebook.get_page_by_enum()
if enum == NotebookPage.SERVERS: if enum == NotebookPage.SERVERS:
+1 -2
View File
@@ -30,8 +30,7 @@ class NoteDialog(GenericDialog):
delete_button = Gtk.Button(label="Delete note") delete_button = Gtk.Button(label="Delete note")
delete_button.set_sensitive(False) delete_button.set_sensitive(False)
self.add_action_widget(delete_button, Gtk.ResponseType.CANCEL) self.add_action_widget(delete_button, Gtk.ResponseType.CANCEL)
self.add_button("Update note", Gtk.ResponseType.OK) self.ok = self.add_button("Update note", Gtk.ResponseType.OK)
self.ok = self.get_widget_for_response(Gtk.ResponseType.OK)
self.ok.grab_default() self.ok.grab_default()
self.entry = ValidatedEntry(controller, self.validate) self.entry = ValidatedEntry(controller, self.validate)
+2 -1
View File
@@ -61,4 +61,5 @@ class CursorMixin:
dest = end dest = end
path = Gtk.TreePath.new_from_indices([dest]) path = Gtk.TreePath.new_from_indices([dest])
self.set_cursor(path) # type: ignore return True self.set_cursor(path) # type: ignore
return True
+2
View File
@@ -313,6 +313,8 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
def mark_finished(self) -> None: def mark_finished(self) -> None:
self.mod_count.set_label(preconnect.all_updated) self.mod_count.set_label(preconnect.all_updated)
model = self.tree.get_model() model = self.tree.get_model()
if model is None:
return
for row in model: for row in model:
row[2] = checkmark row[2] = checkmark
+1 -1
View File
@@ -75,4 +75,4 @@ class MenuTreeView(TreeView):
model = self.get_model() model = self.get_model()
_iter = self.get_focused_row_iter() _iter = self.get_focused_row_iter()
rowtype = model.get_value(_iter, 1) rowtype = model.get_value(_iter, 1)
return rowtype.dict["tooltip"] return str(rowtype.dict["tooltip"])