jw-pkg/src/python/jw/pkg/cmds/secrets/Cmd.py
Jan Lindemann dcbd4b1c84 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>
2026-08-09 11:31:15 +00:00

54 lines
1.9 KiB
Python

from __future__ import annotations
from functools import cached_property
from typing import override, TYPE_CHECKING
from ...CmdBase import CmdBase as Base
from ..CmdSecrets import CmdSecrets as Parent
from .lib.DistroContext import DistroContext
if TYPE_CHECKING:
from collections.abc import Collection
from argparse import ArgumentParser
from .lib.base import Attrs
class Cmd(Base): # export
@cached_property
def ctx(self) -> DistroContext:
return DistroContext(self.app.distro)
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: Collection[str]) -> list[str]:
return await self.ctx.list_template_files(packages)
async def _list_secret_paths(
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: 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: Collection[str]) -> list[str]:
return await self.ctx.remove_compilation_targets(packages)
async def _compile_template_files(
self, packages: Collection[str], default_attrs: Attrs
) -> list[str]:
return await self.ctx.compile_template_files(packages, default_attrs)
def __init__(self, parent: Parent, name: str, help: str) -> None:
super().__init__(parent, name, help)
@override
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('packages', nargs = '*', help = 'Package names')
__all__ = ['Parent', 'Cmd']