mypy: Fix no_untyped_defs
Add type annotations to 30 files across jw.util, resolving all 191 'no-untyped-def' mypy errors in strict mode. The changes cover Signals, CppState, Bunch, RedirectStdIO, StopWatch, Process, Options, ArgsContainer, Object, multi_key_dict, ldap, Session, rows, ShuntingYard, TableIoHandler, DataBase, Queries, Query, QueryResult, and all db/schema files (Column, Table, ColumnSet, DataType, Schema, SingleForeignKey, CompositeForeignKey), plus asyncio variants and ev/base/Object and auth/dummy/Auth. Additionally, unreachable code and type annotation conflicts were resolved in StopWatch.py, Options.py, rows.py, and Table.py. Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v0.82.0 Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
73f52fb609
commit
9323529187
1 changed files with 247 additions and 220 deletions
|
|
@ -1,6 +1,15 @@
|
|||
from typing import Any
|
||||
|
||||
class CppState: # export
|
||||
|
||||
def __init__(self):
|
||||
__pair_square: list[str]
|
||||
__pair_curly: list[str]
|
||||
__pair_ext: list[str]
|
||||
__pair_paren: list[str]
|
||||
__pair_c_comment: list[str]
|
||||
__pair_special: list[str]
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.__pair_square = ['[', ']']
|
||||
self.__pair_curly = ['{', '}']
|
||||
self.__pair_ext = ['<', '>']
|
||||
|
|
@ -9,7 +18,7 @@ class CppState: # export
|
|||
self.__pair_special = ['?', '?']
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
def reset(self) -> None:
|
||||
self.curly = 0
|
||||
self.square = 0
|
||||
self.ext = 0
|
||||
|
|
@ -17,14 +26,14 @@ class CppState: # export
|
|||
self.in_c_comment = False
|
||||
self.in_cpp_comment = False
|
||||
self.in_special = False
|
||||
self.rule = []
|
||||
self.rules = []
|
||||
self.things = []
|
||||
self.rule: list[str] = []
|
||||
self.rules: list[str] = []
|
||||
self.things: list[list[str]] = []
|
||||
|
||||
def optional(self):
|
||||
def optional(self) -> bool:
|
||||
return self.square != 0 or self.curly != 0
|
||||
|
||||
def update(self, tok, line):
|
||||
def update(self, tok: str, line: Any) -> bool | None:
|
||||
if not self.in_comment():
|
||||
if tok == '[':
|
||||
self.square += 1
|
||||
|
|
@ -68,7 +77,7 @@ class CppState: # export
|
|||
if self.in_cpp_comment:
|
||||
if tok == '\n':
|
||||
self.in_cpp_comment = False
|
||||
return
|
||||
return None
|
||||
if tok == '/*':
|
||||
raise Exception("Nested C-style comment", tok, "in line", line)
|
||||
elif tok == '*/':
|
||||
|
|
@ -79,25 +88,25 @@ class CppState: # export
|
|||
raise Exception("Unbalanced BNF bracket", tok, "in line", line)
|
||||
return self.optional()
|
||||
|
||||
def in_list(self):
|
||||
def in_list(self) -> bool:
|
||||
return self.curly > 0
|
||||
|
||||
def in_option(self):
|
||||
def in_option(self) -> bool:
|
||||
return self.square > 0
|
||||
|
||||
def in_paren(self):
|
||||
def in_paren(self) -> bool:
|
||||
return self.paren > 0
|
||||
|
||||
def in_ext(self):
|
||||
def in_ext(self) -> bool:
|
||||
return self.ext > 0
|
||||
|
||||
def in_comment(self):
|
||||
def in_comment(self) -> bool:
|
||||
return self.in_c_comment or self.in_cpp_comment
|
||||
|
||||
def in_something(self):
|
||||
def in_something(self) -> list[str] | None:
|
||||
if len(self.things) == 0:
|
||||
return None
|
||||
return self.things[-1]
|
||||
|
||||
def is_optional(self):
|
||||
def is_optional(self) -> bool:
|
||||
return self.in_list() or self.in_option()
|
||||
|
|
|
|||
Loading…
Reference in a new issue