mypy: Fix warn_return_any type errors

Add proper type annotations to fix mypy warn_return_any errors.
The following files were modified to add cast() calls or return
type annotations where functions returned Any values:

- algo/ShuntingYard.py: Add cast for operator() return value
- auth/Auth.py: Add cast for load() return value, fix imports
- cast.py: Fix cast_str_to_int return type, fix _strip type
- db/TableIoHandler.py: Remove redundant cast, fix store() return
- db/query/Queries.py: Add cast for _run() and __getitem__ returns
- db/query/Query.py: Add cast for db property return
- db/query/QueryResult.py: Add cast for db and query property returns
- db/schema/Schema.py: Add return type to __tables property, cast columns
- db/schema/Table.py: Add cast for model_module_search_paths return
- ev/app/EventRouter.py: Add cast for peer_conf.get() return
- ev/base/Object.py: Add cast for get_conf_section and str_or_none returns
- ev/base/SimpleObject.py: Add cast for create() return, fix imports
- load_yaml.py: Add cast for _expand_links_recursive return
- misc.py: Fix object_builtin_name return type, add param annotations
- stree/StringTree.py: Fix get() return type with default_value variable

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 21:44:20 +02:00 • committed by janware DevOps
commit ec342ba172
Signed by: DevOps
SSH key fingerprint: SHA256:cZiw7ExG5q3KAVm7Jse3rGITowu0VjgUgNMPbifmY8g
6 changed files with 37 additions and 38 deletions

View file

@ -88,4 +88,4 @@ class TableIoHandler(ABC): # export
return ret
def store(self, uri: str, data: TType) -> None:
return self._store(uri, data)
self._store(uri, data)

View file

@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Any, TYPE_CHECKING, override
from typing import Any, cast, TYPE_CHECKING, override
import abc
@ -26,7 +26,7 @@ class Queries(abc.ABC): # export
@override
def _run(self, session, *args, **kwargs) -> QueryResult:
return self.__func(session, *args, **kwargs)
return cast('QueryResult', self.__func(session, *args, **kwargs))
@override
def _register(self):
@ -47,7 +47,7 @@ class Queries(abc.ABC): # export
def __getitem__(self, name) -> Query:
try:
return self.__queries[name]
return cast('Queries.Query', self.__queries[name])
except Exception as e:
slog(ERR, f'Failed to retrieve query {name} ({e})')
slog_m(ERR, '\n'.join(self.__queries.keys()))
@ -68,7 +68,7 @@ class Queries(abc.ABC): # export
@property
def schema(self) -> Schema:
return self.__db.schema
return cast('Schema', self.__db.schema)
def add(self, query: QueryBase, query_name: str, location: str, func: Any):
slog(INFO, f'Adding query "{query_name}" on location "{location}"')

View file

@ -2,7 +2,7 @@ from __future__ import annotations
import abc
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, cast
if TYPE_CHECKING:
from ..DataBase import DataBase
@ -47,7 +47,7 @@ class Query(abc.ABC): # export
@property
def db(self) -> DataBase:
return self.__parent.db
return cast('DataBase', self.__parent.db)
@property
def schema(self):

View file

@ -3,7 +3,7 @@ from __future__ import annotations
import abc
from enum import Enum, auto
from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any, cast, Union
if TYPE_CHECKING:
from ..DataBase import DataBase
@ -24,11 +24,11 @@ class QueryResult(abc.ABC): # export
@property
def db(self) -> DataBase:
return self.__query.db
return cast('DataBase', self.__query.db)
@property
def query(self) -> DataBase:
return self.__query
return cast('DataBase', self.__query)
@property
def session(self) -> Session:

View file

@ -2,7 +2,7 @@ from __future__ import annotations
import abc
from typing import TYPE_CHECKING, override, Iterable, Optional
from typing import TYPE_CHECKING, cast, override, Iterable, Optional
from ...log import DEBUG, ERR, slog, throw
@ -19,9 +19,9 @@ class Schema(abc.ABC): # export
self.__access_defining_columns: Optional[list[str]] = None
@property
def __tables(self):
def __tables(self) -> dict[str, Table]:
if self.___tables is None:
ret = dict()
ret: dict[str, Table] = dict()
for name in self._table_names():
slog(DEBUG, f'Caching metadata for table "{name}"')
assert (isinstance(name, str))
@ -103,7 +103,7 @@ class Schema(abc.ABC): # export
return self.__tables[table_name].primary_keys
def columns(self, table_name: str) -> Iterable[Column]:
return self.__tables[table_name].columns
return cast('Iterable[Column]', self.__tables[table_name].columns)
@property
def model_module_search_paths(self) -> list[tuple[str, type]]:

View file

@ -4,7 +4,7 @@ import abc
import re
from collections import OrderedDict
from typing import TYPE_CHECKING, override
from typing import TYPE_CHECKING, cast, override
from urllib.parse import quote_plus
from ...log import ERR, WARNING, slog, throw
@ -177,7 +177,7 @@ class Table(abc.ABC): # export
def _model_module_search_paths(self) -> list[tuple[str, type]]:
# Fall back to Schema-global default
return self.schema.model_module_search_paths
return cast('list[tuple[str, type]]', self.schema.model_module_search_paths)
@abc.abstractmethod
def _query_name(self) -> str: