lib: Change Iterable to Collection for truthy checks
Change parameter types from Iterable[str] to Collection[str] wherever the parameter is tested for emptiness (if not names). This satisfies the new truthy-iterable mypy rule, since bare Iterable values are always truthy even when empty. Affected files: - Distro.py: install, delete, select, _select, _select_by_name - rpm.py: query_packages - suse/Distro.py: _select_by_name - Cmd.py (secrets): _match_files, _list_template_files, etc. - DistroContext.py: list_template_files, list_secret_paths, etc. 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
cbd6bac84c
commit
dcbd4b1c84
5 changed files with 25 additions and 23 deletions
|
|
@ -8,8 +8,8 @@ from ..CmdSecrets import CmdSecrets as Parent
|
|||
from .lib.DistroContext import DistroContext
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Collection
|
||||
from argparse import ArgumentParser
|
||||
from typing import Iterable
|
||||
|
||||
from .lib.base import Attrs
|
||||
|
||||
|
|
@ -19,27 +19,27 @@ class Cmd(Base): # export
|
|||
def ctx(self) -> DistroContext:
|
||||
return DistroContext(self.app.distro)
|
||||
|
||||
async def _match_files(self, packages: Iterable[str], pattern: str) -> list[str]:
|
||||
async def _match_files(self, packages: Collection[str], pattern: str) -> list[str]:
|
||||
return await self.ctx.match_files(packages, pattern)
|
||||
|
||||
async def _list_template_files(self, packages: Iterable[str]) -> list[str]:
|
||||
async def _list_template_files(self, packages: Collection[str]) -> list[str]:
|
||||
return await self.ctx.list_template_files(packages)
|
||||
|
||||
async def _list_secret_paths(
|
||||
self, packages: Iterable[str], ignore_missing: bool = False
|
||||
self, packages: Collection[str], ignore_missing: bool = False
|
||||
) -> list[str]:
|
||||
return await self.ctx.list_secret_paths(packages, ignore_missing)
|
||||
|
||||
async def _list_compilation_targets(
|
||||
self, packages: Iterable[str], ignore_missing: bool = False
|
||||
self, packages: Collection[str], ignore_missing: bool = False
|
||||
) -> list[str]:
|
||||
return await self.ctx.list_compilation_targets(packages, ignore_missing)
|
||||
|
||||
async def _remove_compilation_targets(self, packages: Iterable[str]) -> list[str]:
|
||||
async def _remove_compilation_targets(self, packages: Collection[str]) -> list[str]:
|
||||
return await self.ctx.remove_compilation_targets(packages)
|
||||
|
||||
async def _compile_template_files(
|
||||
self, packages: Iterable[str], default_attrs: Attrs
|
||||
self, packages: Collection[str], default_attrs: Attrs
|
||||
) -> list[str]:
|
||||
return await self.ctx.compile_template_files(packages, default_attrs)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue