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,6 +1,6 @@
from __future__ import annotations
from typing import override, TYPE_CHECKING
from typing import Any, override, TYPE_CHECKING
from ...Distro import Distro as Base
@ -23,7 +23,7 @@ class Distro(Base):
return await self.sudo(cmd, verbose = verbose)
return await self.run(cmd, verbose = verbose)
def __init__(self, *args, **kwargs):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
@override

View file

@ -2,7 +2,7 @@ from __future__ import annotations
import os
from typing import override, TYPE_CHECKING
from typing import Any, override, TYPE_CHECKING
from ...Distro import Distro as Base
from ...log import NOTICE, log
@ -31,11 +31,11 @@ class Distro(Base):
if sudo else await self.run(cmd, verbose = verbose)
)
async def dpkg(self, *args, **kwargs) -> str:
async def dpkg(self, *args: Any, **kwargs: Any) -> str:
kwargs.setdefault('ec', self.ctx)
return await run_dpkg(*args, **kwargs)
def __init__(self, *args, **kwargs):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
@override

View file

@ -1,6 +1,6 @@
from __future__ import annotations
from typing import override, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, override
from ...Distro import Distro as Base
from ...pm.rpm import list_files, query_packages, run_rpm
@ -35,13 +35,18 @@ class Distro(Base):
if sudo else await self.run(cmd, verbose = verbose)
)
async def rpm(self, *args, ec: ExecContext | None = None, **kwargs) -> str:
async def rpm(
self,
*args: Any,
ec: ExecContext | None = None,
**kwargs: Any,
) -> str:
if ec is None:
ec = self.ctx
kwargs['ec'] = ec
return await run_rpm(*args, **kwargs)
def __init__(self, *args, **kwargs):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
@override