This commit adds @override decorators to approximately 300 methods across 76 files that inherit from base classes such as AbstractCmd, FileContext, ExecContext, Distro, SSHClient, and others. The decorator ensures the type checker can verify that overridden methods have compatible signatures and prevents accidental shadowing of inherited methods without intent. Files modified include command classes, library modules, distro implementations, and SSH client implementations. Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL with pi.dev v Signed-off-by: Jan Lindemann <jan@janware.com>
62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
from __future__ import annotations
|
|
import re
|
|
|
|
from ...lib.log import DEBUG, log
|
|
from .Cmd import Cmd, Parent
|
|
from typing import TYPE_CHECKING, override
|
|
|
|
if TYPE_CHECKING:
|
|
from argparse import ArgumentParser, Namespace
|
|
|
|
class CmdModules(Cmd): # export
|
|
|
|
def __init__(self, parent: Parent) -> None:
|
|
super().__init__(parent, 'modules', help = 'Query existing janware packages')
|
|
|
|
@override
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
super().add_arguments(parser)
|
|
parser.add_argument(
|
|
'-F',
|
|
'--filter',
|
|
nargs = '?',
|
|
default = None,
|
|
help =
|
|
'Key-value pairs, seperated by commas, to be searched for in project.conf',
|
|
)
|
|
|
|
@override
|
|
async def _run(self, args: Namespace) -> None:
|
|
import pathlib
|
|
|
|
proj_root = self.app.projs_root
|
|
log(DEBUG, 'proj_root = ' + proj_root)
|
|
path = pathlib.Path(self.app.projs_root)
|
|
modules = [p.parents[1].name for p in path.glob('*/make/project.conf')]
|
|
log(DEBUG, 'modules = ', modules)
|
|
out = []
|
|
filters = (
|
|
None if args.filter is None else
|
|
[re.split('=', f) for f in re.split(',', args.filter)]
|
|
)
|
|
for m in modules:
|
|
if not filters:
|
|
out.append(m)
|
|
continue
|
|
for f in filters:
|
|
path_str = f[0].rsplit('.')
|
|
if len(path_str) > 1:
|
|
sec = path_str[0]
|
|
key = path_str[1]
|
|
else:
|
|
sec = None
|
|
key = path_str[0]
|
|
val = self.app.get_value(m, sec, key)
|
|
log(
|
|
DEBUG,
|
|
'Checking in {} if {}="{}", is "{}"'.format(m, f[0], f[1], val),
|
|
)
|
|
if val and val == f[1]:
|
|
out.append(m)
|
|
break
|
|
print(' '.join(out))
|