mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
chore: clear typehinting errors
This commit is contained in:
1 parent
ea1b9facd2
commit
2ebe8cad84
9 files changed
+35
-27
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Any, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from dzgui.const.constants import APP_NAME
|
from dzgui.const.constants import APP_NAME
|
||||||
from dzgui.const.endpoints import BM_SERVERS
|
from dzgui.const.endpoints import BM_SERVERS
|
||||||
@@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||||||
from dzgui.api.servers import Record
|
from dzgui.api.servers import Record
|
||||||
|
|
||||||
|
|
||||||
def get_attributes(key: str, uid: int) -> str:
|
def get_attributes(key: str, uid: int) -> Any:
|
||||||
# TODO: handle if key is not set
|
# TODO: handle if key is not set
|
||||||
# TODO: tests for malformed IDs/values
|
# TODO: tests for malformed IDs/values
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ def ping(ip: str, qport: int) -> int:
|
|||||||
if res is None:
|
if res is None:
|
||||||
return 9999
|
return 9999
|
||||||
else:
|
else:
|
||||||
return res["ping"]
|
return int(res["ping"])
|
||||||
except Exception:
|
except Exception:
|
||||||
return 9999
|
return 9999
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def rc2json(file: Path) -> str:
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
tok = lex.get_token()
|
tok = lex.get_token()
|
||||||
ntok = lex.get_token()
|
ntok: str | bool | None = lex.get_token()
|
||||||
|
|
||||||
if ntok is not None:
|
if ntok is not None:
|
||||||
ntok = ntok.strip('""')
|
ntok = ntok.strip('""')
|
||||||
@@ -58,7 +58,8 @@ def rc2json(file: Path) -> str:
|
|||||||
if tok in deprecated:
|
if tok in deprecated:
|
||||||
continue
|
continue
|
||||||
elif tok in toggles:
|
elif tok in toggles:
|
||||||
ntok = str2bool(ntok)
|
if ntok is not None:
|
||||||
|
ntok = str2bool(ntok)
|
||||||
elif tok == "preferred_client":
|
elif tok == "preferred_client":
|
||||||
tok = "client"
|
tok = "client"
|
||||||
elif tok == "api_key":
|
elif tok == "api_key":
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def lookup(path: Path, enum: Preferences) -> Any:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_config(path: Path) -> dict:
|
def get_config(path: Path) -> Any:
|
||||||
# TODO: is this being called multiple times?
|
# TODO: is this being called multiple times?
|
||||||
try:
|
try:
|
||||||
json = read_json(path)
|
json = read_json(path)
|
||||||
@@ -37,7 +37,7 @@ def get_favorites(path: Path) -> list[str]:
|
|||||||
conf = get_config(path)
|
conf = get_config(path)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return conf["ip_list"]
|
return list(conf["ip_list"])
|
||||||
|
|
||||||
|
|
||||||
# def is_in_favs(record: str, path: Path) -> bool:
|
# def is_in_favs(record: str, path: Path) -> bool:
|
||||||
|
|||||||
+4
-1
@@ -54,7 +54,10 @@ def get_xdg_paths() -> dict:
|
|||||||
resolved_paths = {}
|
resolved_paths = {}
|
||||||
for path in xdg_paths:
|
for path in xdg_paths:
|
||||||
rp = os.environ.get(path)
|
rp = os.environ.get(path)
|
||||||
resolved_paths[path] = Path(rp) / APP_NAME_LOWER if is_writeable(rp) else xdg_paths[path] / APP_NAME_LOWER
|
if rp is not None and is_writeable(rp):
|
||||||
|
resolved_paths[path] = Path(rp)
|
||||||
|
else:
|
||||||
|
resolved_paths[path] = xdg_paths[path] / APP_NAME_LOWER
|
||||||
return resolved_paths
|
return resolved_paths
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class FastInsertListStore(ListStore):
|
|||||||
for row in rows:
|
for row in rows:
|
||||||
self.append(row)
|
self.append(row)
|
||||||
|
|
||||||
def append(self, row: list[Any] | tuple[Any, ...] | None = ...) -> TreeIter:
|
def append(self, row: list[Any] | tuple[Any, ...] | None = ...) -> TreeIter: # type: ignore
|
||||||
# FIXME: argument cannot be none
|
# FIXME: argument cannot be none
|
||||||
"""
|
"""
|
||||||
Optimized for speed, but makes no assurances about row homogeneity
|
Optimized for speed, but makes no assurances about row homogeneity
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ logger = logging.getLogger(APP_NAME)
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.const.enum import NotebookPage
|
from dzgui.const.enum import NotebookPage
|
||||||
from dzgui.controller.mc import Controller
|
from dzgui.controllers.mc import Controller
|
||||||
from dzgui.controllers.emitter import Emitter
|
from dzgui.controllers.emitter import Emitter
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class ContextMixin(TreeView):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _on_menu_click(self, widget: Gtk.MenuItem, enum: ContextMenu) -> None:
|
def _on_menu_click(self, widget: Gtk.MenuItem, enum: ContextMenu) -> None:
|
||||||
self.controller.menu_action(enum, self)
|
self.controller.menu_action(enum, self) # type: ignore
|
||||||
|
|
||||||
def _on_key(self, menu: Gtk.Menu, event: Gdk.EventKey) -> bool | None:
|
def _on_key(self, menu: Gtk.Menu, event: Gdk.EventKey) -> bool | None:
|
||||||
if not is_navkey(event.keyval):
|
if not is_navkey(event.keyval):
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
def get_focused_row_iter(self) -> Gtk.TreeIter:
|
def get_focused_row_iter(self) -> Gtk.TreeIter:
|
||||||
path = self.get_focused_row_path()
|
path = self.get_focused_row_path()
|
||||||
model = self.get_model()
|
model = self.get_model()
|
||||||
|
if model is None:
|
||||||
|
raise AttributeError("No model attached to tree")
|
||||||
return model.get_iter(path)
|
return model.get_iter(path)
|
||||||
|
|
||||||
def get_focused_row_path(self) -> Gtk.TreePath:
|
def get_focused_row_path(self) -> Gtk.TreePath:
|
||||||
@@ -106,9 +108,10 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
# self.get_selection().select_iter(it)
|
# self.get_selection().select_iter(it)
|
||||||
# return True
|
# return True
|
||||||
|
|
||||||
if self.get_model() is None:
|
model = self.get_model()
|
||||||
|
if model is None:
|
||||||
return
|
return
|
||||||
if len(self.get_model()) < 2:
|
if len(model) < 2:
|
||||||
return
|
return
|
||||||
if is_navkey(event.keyval):
|
if is_navkey(event.keyval):
|
||||||
if self.sel_blocked is True:
|
if self.sel_blocked is True:
|
||||||
@@ -144,7 +147,7 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
path = pathlist[0]
|
path = pathlist[0]
|
||||||
tree_iter = model.get_iter(path)
|
tree_iter = model.get_iter(path)
|
||||||
value = model.get_value(tree_iter, index)
|
value = model.get_value(tree_iter, index)
|
||||||
return value
|
return str(value)
|
||||||
|
|
||||||
def get_name(self) -> str:
|
def get_name(self) -> str:
|
||||||
name = self.get_value_at_index(0)
|
name = self.get_value_at_index(0)
|
||||||
@@ -161,12 +164,12 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
return (model, pathlist)
|
return (model, pathlist)
|
||||||
|
|
||||||
@deprecated("Currently unused")
|
@deprecated("Currently unused")
|
||||||
def get_mpath(self) -> Optional[Gtk.TreePath]:
|
#def get_mpath(self) -> Optional[Gtk.TreePath]:
|
||||||
(model, pathlist) = self.get_model_and_pathlist()
|
# (model, pathlist) = self.get_model_and_pathlist()
|
||||||
if len(pathlist) < 1:
|
# if len(pathlist) < 1:
|
||||||
return None
|
# return None
|
||||||
path = pathlist[0]
|
# path = pathlist[0]
|
||||||
return path
|
# return path
|
||||||
|
|
||||||
def _on_row_activated(
|
def _on_row_activated(
|
||||||
self,
|
self,
|
||||||
@@ -182,13 +185,14 @@ class TreeView(CursorMixin, Gtk.TreeView): # type: ignore
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_selected_row(self) -> Optional[Gtk.TreeModelRow]:
|
@deprecated("unused")
|
||||||
ind = self.get_selected_row_index()
|
#def get_selected_row(self) -> Optional[Gtk.TreeModelRow]:
|
||||||
model = self.get_model()
|
# ind = self.get_selected_row_index()
|
||||||
if model is None:
|
# model = self.get_model()
|
||||||
return None
|
# if model is None:
|
||||||
row = model[ind]
|
# return None
|
||||||
return row
|
# row = model[ind]
|
||||||
|
# return row
|
||||||
|
|
||||||
def get_col_value_by_path_index(self, path: Gtk.TreePath, index: int) -> Any:
|
def get_col_value_by_path_index(self, path: Gtk.TreePath, index: int) -> Any:
|
||||||
model = self.get_model()
|
model = self.get_model()
|
||||||
|
|||||||
Reference in new issue
Block a user