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
3 changed files with 80 additions and 78 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Union, cast
|
||||
|
||||
from ..log import ERR, INFO, OFF, slog, slog_m
|
||||
from .rows import rows_check_not_null, rows_dump, rows_duplicates
|
||||
|
|
@ -76,10 +76,7 @@ class TableIoHandler(ABC): # export
|
|||
self, uri: str, reference, check_duplicates = False, write_csv = None
|
||||
) -> TType:
|
||||
slog(INFO, f'Reading table "{self._table_name}" from "{uri}"')
|
||||
ret = self._load(uri, reference)
|
||||
if check_duplicates:
|
||||
slog(INFO, f'Checking duplicates in {self._table_name}')
|
||||
d = rows_duplicates(ret)
|
||||
ret = cast('List[Dict[str, Any]]', self._load(uri, reference))
|
||||
if check_duplicates:
|
||||
slog(INFO, f'Checking duplicates in {self._table_name}')
|
||||
d = rows_duplicates(ret)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import os
|
|||
import re
|
||||
import textwrap
|
||||
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
from tabulate import TableFormat, tabulate # type: ignore[import-untyped]
|
||||
|
||||
|
|
@ -247,10 +247,9 @@ def rows_dumps( # export
|
|||
|
||||
assert isinstance(tablefmt, str) or isinstance(tablefmt, TableFormat), 'tablefmt'
|
||||
return cast(
|
||||
str,
|
||||
header + heading + lead + tabulate(
|
||||
dump_rows, headers = headers, tablefmt = tablefmt
|
||||
) + footer
|
||||
'str',
|
||||
header + heading + lead +
|
||||
tabulate(dump_rows, headers = headers, tablefmt = tablefmt) + footer
|
||||
)
|
||||
|
||||
def rows_dump( # export
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ class CompositeForeignKey: # export
|
|||
self, child_col_set: ColumnSet, parent_col_set: ColumnSet
|
||||
): # TODO: Implement alternative ways to construct
|
||||
|
||||
def __table(s) -> Table:
|
||||
ret: Table | None = None
|
||||
def __table(s) -> 'Table':
|
||||
ret: 'Table | None' = None
|
||||
for c in s:
|
||||
if ret is None:
|
||||
ret = cast(Table, c.table)
|
||||
ret = cast('Table', c.table)
|
||||
else:
|
||||
assert (ret == c.table)
|
||||
assert (ret is not None)
|
||||
|
|
|
|||
Loading…
Reference in a new issue