App, cmds, lib: Fix Any returns from typed functions

Add type annotations and casts to functions that were returning Any
where a specific type was declared, satisfying the new warn_return_any
mypy rule.

Fixes:
- log.py: get_caller_pos return type via cast
- AsyncRunner.py: cast T for fut.result()
- util.py: cast for getattr result, str() for args.username
- FileContext.py: verbose_default bool annotation
- SSHClient.py: cast SSHClient for dynamic import
- lib/App.py: cast ArgumentParser, add return types to inner funcs
- pm/rpm.py, dpkg.py: cast Iterable[Package]
- App.py: cast for self.args.func(), add return types to inner funcs
- BaseCmdPkgRelations.py: cast str for args.delimiter

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev 0.81.1
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-07-22 23:03:53 +02:00
commit 1e613a39c6
40 changed files with 228 additions and 179 deletions

View file

@ -1,4 +1,3 @@
from typing import Any, override
import asyncio
import os
import shlex
@ -6,8 +5,12 @@ import shutil
import signal
import sys
from typing import Any, override
import asyncssh # type: ignore[import-not-found, unused-ignore]
from asyncssh import SSHReader # type: ignore[import-not-found, unused-ignore]
from ...base import Result
from ...log import DEBUG, ERR, NOTICE, log
from ..SSHClient import SSHClient as Base
@ -22,10 +25,10 @@ class AsyncSSH(Base):
uri: str,
*,
client_keys: list[str] | None = None,
known_hosts = _USE_DEFAULT_KNOWN_HOSTS,
known_hosts: Any = _USE_DEFAULT_KNOWN_HOSTS,
term_type: str | None = None,
connect_timeout: float | None = 30.0,
**kwargs,
**kwargs: Any,
) -> None:
super().__init__(
@ -121,8 +124,8 @@ class AsyncSSH(Base):
async def _read_stream(
self,
stream,
prio,
stream: SSHReader[bytes],
prio: int,
collector: list[bytes],
*,
verbose: bool,
@ -222,7 +225,7 @@ class AsyncSSH(Base):
stdout_parts.append(chunk)
_write_local(chunk)
def _on_winch(*_args) -> None:
def _on_winch(*_args: Any) -> None:
try:
proc.change_terminal_size(*self._get_local_term_size())