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 <jan@janware.com>
This commit is contained in:
parent
7f1809d6d1
commit
49bf2b2442
3 changed files with 9 additions and 7 deletions
|
|
@ -3,14 +3,14 @@ from __future__ import annotations
|
||||||
import abc
|
import abc
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, override
|
from typing import TYPE_CHECKING, Any, override
|
||||||
|
|
||||||
from .log import ERR
|
from .log import ERR
|
||||||
from .Types import LoadTypes, Types
|
from .Types import LoadTypes, Types
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from typing import Any, Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from .App import App
|
from .App import App
|
||||||
|
|
||||||
|
|
@ -84,7 +84,9 @@ class AbstractCmd(abc.ABC):
|
||||||
if exit_status is not None:
|
if exit_status is not None:
|
||||||
sys.exit(exit_status)
|
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):
|
if isinstance(cmds, Cmd):
|
||||||
assert False
|
assert False
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ class Distro(abc.ABC):
|
||||||
def macros(cls) -> list[str]:
|
def macros(cls) -> list[str]:
|
||||||
return ['%%{' + name + '}' for name in cls.macro_names]
|
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]
|
ret: str | list[str]
|
||||||
if not isinstance(fmt, str):
|
if not isinstance(fmt, str):
|
||||||
ret = []
|
ret = []
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import override
|
from typing import Any, override
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
|
@ -58,8 +58,8 @@ class AsyncSSH(Base):
|
||||||
log(DEBUG, f'Failed to close connection ({str(e)}, ignored)')
|
log(DEBUG, f'Failed to close connection ({str(e)}, ignored)')
|
||||||
self.__conn = None
|
self.__conn = None
|
||||||
|
|
||||||
def _connect_kwargs(self, hide_secrets: bool = False) -> dict:
|
def _connect_kwargs(self, hide_secrets: bool = False) -> dict[str, Any]:
|
||||||
kwargs: dict = {
|
kwargs: dict[str, Any] = {
|
||||||
'host': self.hostname,
|
'host': self.hostname,
|
||||||
'port': self.port,
|
'port': self.port,
|
||||||
'username': self.username,
|
'username': self.username,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue