From 49bf2b2442ce273e8e4c94bef3d90297ae9c1462 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 22 Jul 2026 22:19:16 +0200 Subject: [PATCH] Distro, Cmd, AsyncSSH: Fix bare generic types Add explicit type arguments to all generic type annotations that were previously bare, satisfying the new disallow_any_generics mypy rule. Fixes: - Distro.py: Iterable[str] for expand_macros fmt parameter - Cmd.py: Types[Any] for add_subcommands cmds parameter - AsyncSSH.py: dict[str, Any] for _connect_kwargs return type Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev 0.81.1 Signed-off-by: Jan Lindemann --- src/python/jw/pkg/lib/Cmd.py | 8 +++++--- src/python/jw/pkg/lib/Distro.py | 2 +- src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/python/jw/pkg/lib/Cmd.py b/src/python/jw/pkg/lib/Cmd.py index ffa76fa6..2d1375cb 100644 --- a/src/python/jw/pkg/lib/Cmd.py +++ b/src/python/jw/pkg/lib/Cmd.py @@ -3,14 +3,14 @@ from __future__ import annotations import abc import sys -from typing import TYPE_CHECKING, override +from typing import TYPE_CHECKING, Any, override from .log import ERR from .Types import LoadTypes, Types if TYPE_CHECKING: from argparse import ArgumentParser - from typing import Any, Iterable + from typing import Iterable from .App import App @@ -84,7 +84,9 @@ class AbstractCmd(abc.ABC): if exit_status is not None: sys.exit(exit_status) - def add_subcommands(self, cmds: Cmd | list[Cmd] | Types | list[Types]) -> None: + def add_subcommands( + self, cmds: Cmd | list[Cmd] | Types[Any] | list[Types[Any]] + ) -> None: if isinstance(cmds, Cmd): assert False return diff --git a/src/python/jw/pkg/lib/Distro.py b/src/python/jw/pkg/lib/Distro.py index 369facf9..5accdab1 100644 --- a/src/python/jw/pkg/lib/Distro.py +++ b/src/python/jw/pkg/lib/Distro.py @@ -278,7 +278,7 @@ class Distro(abc.ABC): def macros(cls) -> list[str]: return ['%%{' + name + '}' for name in cls.macro_names] - def expand_macros(self, fmt: str | Iterable) -> str | list[str]: + def expand_macros(self, fmt: str | Iterable[str]) -> str | list[str]: ret: str | list[str] if not isinstance(fmt, str): ret = [] diff --git a/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py b/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py index 13f452fe..127e2ef6 100644 --- a/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py +++ b/src/python/jw/pkg/lib/ec/ssh/AsyncSSH.py @@ -1,4 +1,4 @@ -from typing import override +from typing import Any, override import asyncio import os import shlex @@ -58,8 +58,8 @@ class AsyncSSH(Base): log(DEBUG, f'Failed to close connection ({str(e)}, ignored)') self.__conn = None - def _connect_kwargs(self, hide_secrets: bool = False) -> dict: - kwargs: dict = { + def _connect_kwargs(self, hide_secrets: bool = False) -> dict[str, Any]: + kwargs: dict[str, Any] = { 'host': self.hostname, 'port': self.port, 'username': self.username,