mypy: Fix disallow_untyped_calls type errors
Add return type annotations and fix type mismatches to satisfy disallow_untyped_calls: - ShuntingYard.py: Operator.func -> Any|None, add assert for None - ShellCmd.py: format_cmdline, __reap, __exec, __cleanup, SubprocessProtocol.__init__ return types, fix unreachable code - TableIoHandler.py: cast _load() return to List[Dict[str, Any]] - rows.py: add cast import, cast rows_dumps() return - CompositeForeignKey.py: __table() cast fix, remove TYPE_CHECKING - ldap.py: collect() parameter type ObjectClass - multi_key_dict.py: get(), itervalues(), test function types, fix variable name conflicts, add set[Any] annotations 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
e014a9251f
commit
4fda12ce6a
1 changed files with 80 additions and 78 deletions
|
|
@ -11,7 +11,7 @@ ARG, KEYW, QUOTED, LPAREN, RPAREN = 'arg kw quoted ( )'.split()
|
|||
class Operator: # export
|
||||
|
||||
def __init__(self, func = None, nargs: int = 2, precedence: int = 3, assoc = L):
|
||||
self.func = func
|
||||
self.func: Any | None = func
|
||||
self.nargs = nargs
|
||||
self.prec = precedence
|
||||
self.assoc = assoc
|
||||
|
|
@ -100,17 +100,11 @@ class ShuntingYard(object): # export
|
|||
)
|
||||
|
||||
#self.debug(tokens)
|
||||
return cast(list[tuple[str, Any]], tokens)
|
||||
r = []
|
||||
for e in tokens:
|
||||
if e[0] == "quoted":
|
||||
r.append(e[1][1:-1])
|
||||
else:
|
||||
r.append(e[1])
|
||||
return cast('list[tuple[str, Any]]', tokens)
|
||||
|
||||
return r
|
||||
|
||||
def add_operator(self, name: str, func: Any, nargs: int, precedence: int, assoc: Any) -> None:
|
||||
def add_operator(
|
||||
self, name: str, func: Any, nargs: int, precedence: int, assoc: Any
|
||||
) -> None:
|
||||
self.__ops[name] = Operator(func, nargs, precedence, assoc)
|
||||
|
||||
def infix_to_postfix(self, infix) -> list[str]:
|
||||
|
|
@ -196,7 +190,7 @@ class ShuntingYard(object): # export
|
|||
for (width, cell) in zip(maxcolwidths, row)
|
||||
)
|
||||
)
|
||||
return cast(list[str], table[-1][2])
|
||||
return cast('list[str]', table[-1][2])
|
||||
|
||||
def infix_to_postfix_orig(self, infix):
|
||||
|
||||
|
|
@ -262,6 +256,7 @@ class ShuntingYard(object): # export
|
|||
self.debug("Adding argument %d" % (i))
|
||||
args.append(vals.pop())
|
||||
#self.debug("running %s(%s)" % (token, ', '.join(reversed(args))))
|
||||
assert op.func is not None
|
||||
val = op.func(*reversed(args))
|
||||
self.debug(
|
||||
"%s(%s) = %s" % (token, ', '.join(map(str, reversed(args))), val)
|
||||
|
|
|
|||
Loading…
Reference in a new issue