From 3a7fb5097993abb3a38a9e3cf56123997840c70c Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sun, 15 Dec 2024 15:35:29 +0100 Subject: [PATCH] Apply monkeytype traces Run monkeytype run jw-acc.py --log-level debug db import --format mdb-json-dir dbs monkeytype list-modules | grep ^jw | while read m; do monkeytype apply $m done and fix the fallout. Signed-off-by: Jan Lindemann --- tools/python/jwutils/log.py | 6 +++--- tools/python/jwutils/stree/StringTree.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/python/jwutils/log.py b/tools/python/jwutils/log.py index bdce9ee..240e2b6 100644 --- a/tools/python/jwutils/log.py +++ b/tools/python/jwutils/log.py @@ -5,7 +5,7 @@ import inspect import re from os.path import basename from datetime import datetime -from typing import List, Tuple +from typing import List, Tuple, Optional, Any from . import misc # --- python 2 / 3 compatibility stuff @@ -88,7 +88,7 @@ _prio_colors = { EMERG : [ CONSOLE_FONT_BOLD + CONSOLE_FONT_MAGENTA, CONSOLE_FONT_OFF ], } -def get_caller_pos(up: int = 1, kwargs=None) -> Tuple[str, int]: +def get_caller_pos(up: int = 1, kwargs: Optional[dict[str, Any]] = None) -> Tuple[str, int]: if kwargs and 'caller' in kwargs: r = kwargs['caller'] del kwargs['caller'] @@ -114,7 +114,7 @@ def slog_m(prio: int, *args, **kwargs) -> None: # export for line in margs[1:].split('\n'): slog(prio, line, **kwargs, caller=caller) -def slog(prio: int, *args, only_printable=False, **kwargs) -> None: # export +def slog(prio: int, *args, only_printable: bool=False, **kwargs) -> None: # export if prio > _level: return diff --git a/tools/python/jwutils/stree/StringTree.py b/tools/python/jwutils/stree/StringTree.py index 50c59ed..2f9d0b4 100644 --- a/tools/python/jwutils/stree/StringTree.py +++ b/tools/python/jwutils/stree/StringTree.py @@ -1,6 +1,7 @@ from __future__ import annotations from collections import OrderedDict -from typing import Optional, Union +from typing import Any, List, Optional, Union + from jwutils.log import * def quote(s): @@ -36,7 +37,7 @@ class StringTree: # export def __init__(self, path: str, content: str) -> None: slog(DEBUG, "ctor, path =", path, "content =", content) self.children: OrderedDict[str, StringTree] = OrderedDict() - self.content = None + self.content: Optional[str] = None self.__set(path, content) assert(hasattr(self, "content")) #assert self.content is not None @@ -180,7 +181,7 @@ class StringTree: # export raise Exception('tried to get value from leave "{}"'.format(self.content)) return self.children[next(reversed(self.children))].content # type: ignore - def child_list(self, depth_first=True): + def child_list(self, depth_first: bool=True) -> List[StringTree]: if depth_first == False: raise Exception("tried to retrieve child list with breadth-first search, not yet implemented") r = []