mypy: Fix fallout of ignore-without-code

Fix fallout of mypy --enable-error-code=ignore-without-code check.

The multi_key_dict class had several type issues: the keys() and values()
methods could implicitly return None when a key type was specified but not
found, pyright flagged the conditional items() redefinition, and six test
call sites carried bare "# type: ignore" comments.

Add from __future__ import annotations, a _keys_from_dict() helper, and
proper parameter/return type annotations to keys(), values(), and items().
Consolidate the conditional Python 2/3 items() into a single function with
runtime dispatch. Remove all six bare type-ignores from multi_key_dict.py
and annotate the remaining pre-existing ones in other files with specific
error codes required by ignore-without-code.

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:
Jan Lindemann 2026-07-24 18:14:24 +02:00 • committed by janware DevOps
commit 241aa79120
Signed by: DevOps
SSH key fingerprint: SHA256:cZiw7ExG5q3KAVm7Jse3rGITowu0VjgUgNMPbifmY8g
3 changed files with 41 additions and 35 deletions

View file

@ -5,7 +5,7 @@ import os
import re
import textwrap
from tabulate import TableFormat, tabulate # type: ignore
from tabulate import TableFormat, tabulate # type: ignore[import-untyped]
from ..log import (ERR, INFO, WARNING, get_caller_pos, prio_gets_logged, slog, slog_m)

View file

@ -120,7 +120,7 @@ class Column(abc.ABC): # export
def foreign_key(self, table) -> Optional[Any]:
if self.__foreign_keys_by_table is None:
self.__foreign_keys_by_table = dict()
for col in self.foreign_keys: # type: ignore # Any not iterable
for col in self.foreign_keys: # type: ignore[union-attr] # Any not iterable
assert (col.table.name not in self.__foreign_keys_by_table)
self.__foreign_keys_by_table[col.table.name] = col
table_name = table if isinstance(table, str) else table.name

View file

@ -39,7 +39,7 @@ class Schema(abc.ABC): # export
@abc.abstractmethod
def _table(self, name: str) -> Table:
throw(ERR, "Called pure virtual base class method")
return None # type: ignore
return None # type: ignore[return-value]
@abc.abstractmethod
def _foreign_keys(self) -> list[CompositeForeignKey]:
@ -97,7 +97,7 @@ class Schema(abc.ABC): # export
return table
if throw:
raise Exception(f'Table "{name}" not found in database metadata')
return None # type: ignore
return None # type: ignore[return-value]
def primary_keys(self, table_name: str) -> Iterable[str]:
return self.__tables[table_name].primary_keys