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>
2026-07-25 10:24:57 +02:00
|
|
|
from typing import Any
|
|
|
|
|
|
2026-06-10 13:28:35 +02:00
|
|
|
class CppState: # export
|
2019-06-03 10:00:04 +02:00
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
__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:
|
2019-06-03 10:00:04 +02:00
|
|
|
self.__pair_square = ['[', ']']
|
|
|
|
|
self.__pair_curly = ['{', '}']
|
|
|
|
|
self.__pair_ext = ['<', '>']
|
|
|
|
|
self.__pair_paren = ['(', ')']
|
|
|
|
|
self.__pair_c_comment = ['/*', '*/']
|
|
|
|
|
self.__pair_special = ['?', '?']
|
|
|
|
|
self.reset()
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def reset(self) -> None:
|
2019-06-03 10:00:04 +02:00
|
|
|
self.curly = 0
|
|
|
|
|
self.square = 0
|
|
|
|
|
self.ext = 0
|
|
|
|
|
self.paren = 0
|
|
|
|
|
self.in_c_comment = False
|
|
|
|
|
self.in_cpp_comment = False
|
|
|
|
|
self.in_special = False
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
self.rule: list[str] = []
|
|
|
|
|
self.rules: list[str] = []
|
|
|
|
|
self.things: list[list[str]] = []
|
2019-06-03 10:00:04 +02:00
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def optional(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.square != 0 or self.curly != 0
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def update(self, tok: str, line: Any) -> bool | None:
|
2019-06-03 10:00:04 +02:00
|
|
|
if not self.in_comment():
|
|
|
|
|
if tok == '[':
|
|
|
|
|
self.square += 1
|
|
|
|
|
self.things.append(self.__pair_square)
|
|
|
|
|
elif tok == ']':
|
|
|
|
|
self.square -= 1
|
2026-06-10 13:28:35 +02:00
|
|
|
assert (self.things.pop() == self.__pair_square)
|
2019-06-03 10:00:04 +02:00
|
|
|
elif tok == '{':
|
|
|
|
|
self.curly += 1
|
|
|
|
|
self.things.append(self.__pair_curly)
|
|
|
|
|
elif tok == '}':
|
|
|
|
|
self.curly -= 1
|
2026-06-10 13:28:35 +02:00
|
|
|
assert (self.things.pop() == self.__pair_curly)
|
2019-06-03 10:00:04 +02:00
|
|
|
elif tok == '(':
|
|
|
|
|
self.paren += 1
|
|
|
|
|
self.things.append(self.__pair_paren)
|
|
|
|
|
elif tok == ')':
|
|
|
|
|
self.paren -= 1
|
2026-06-10 13:28:35 +02:00
|
|
|
assert (self.things.pop() == self.__pair_paren)
|
2019-06-03 10:00:04 +02:00
|
|
|
elif tok == '<':
|
|
|
|
|
self.ext += 1
|
|
|
|
|
self.things.append(self.__pair_ext)
|
|
|
|
|
elif tok == '>':
|
|
|
|
|
self.ext -= 1
|
2026-06-10 13:28:35 +02:00
|
|
|
assert (self.things.pop() == self.__pair_ext)
|
2019-06-03 10:00:04 +02:00
|
|
|
elif tok == '?':
|
|
|
|
|
if not self.in_special:
|
|
|
|
|
self.in_special = True
|
|
|
|
|
self.things.append(self.__pair_special)
|
|
|
|
|
else:
|
|
|
|
|
self.in_special = False
|
2026-06-10 13:28:35 +02:00
|
|
|
assert (self.things.pop() == self.__pair_special)
|
2019-06-03 10:00:04 +02:00
|
|
|
elif tok == '/*':
|
|
|
|
|
self.in_c_comment = True
|
|
|
|
|
self.things.append(self.__pair_c_comment)
|
|
|
|
|
elif tok == '*/':
|
2026-06-10 13:28:35 +02:00
|
|
|
raise Exception(
|
|
|
|
|
"Unmatched closing C-style comment mark", tok, "in line", line
|
|
|
|
|
)
|
2019-06-03 10:00:04 +02:00
|
|
|
else:
|
|
|
|
|
if self.in_cpp_comment:
|
|
|
|
|
if tok == '\n':
|
|
|
|
|
self.in_cpp_comment = False
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
return None
|
2019-06-03 10:00:04 +02:00
|
|
|
if tok == '/*':
|
|
|
|
|
raise Exception("Nested C-style comment", tok, "in line", line)
|
|
|
|
|
elif tok == '*/':
|
2026-06-10 13:28:35 +02:00
|
|
|
assert (self.things.pop() == self.__pair_c_comment)
|
2019-06-03 10:00:04 +02:00
|
|
|
self.in_c_comment = False
|
|
|
|
|
|
|
|
|
|
if self.curly < 0 or self.square < 0 or self.ext < 0 or self.paren < 0:
|
|
|
|
|
raise Exception("Unbalanced BNF bracket", tok, "in line", line)
|
|
|
|
|
return self.optional()
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def in_list(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.curly > 0
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def in_option(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.square > 0
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def in_paren(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.paren > 0
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def in_ext(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.ext > 0
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def in_comment(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.in_c_comment or self.in_cpp_comment
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def in_something(self) -> list[str] | None:
|
2019-06-03 10:00:04 +02:00
|
|
|
if len(self.things) == 0:
|
|
|
|
|
return None
|
|
|
|
|
return self.things[-1]
|
|
|
|
|
|
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>
2026-07-25 10:24:57 +02:00
|
|
|
def is_optional(self) -> bool:
|
2019-06-03 10:00:04 +02:00
|
|
|
return self.in_list() or self.in_option()
|