jw-pkg/src/python/jw/pkg/cmds/posix/CmdCopy.py
Jan Lindemann 5fa008be5a
App, lib, cmds: Fix mypy.explicit-override fallout
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>
2026-08-07 18:02:26 +02:00

56 lines
1.7 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING, override
from ...lib.util import copy
from .Cmd import Cmd, Parent
if TYPE_CHECKING:
from argparse import ArgumentParser, Namespace
class CmdCopy(Cmd): # export
def __init__(self, parent: Parent) -> None:
super().__init__(parent, 'copy', help = 'Copy files')
@override
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('src', help = 'Source file URI')
parser.add_argument('dst', help = 'Destination file URI')
parser.add_argument(
'-o', '--owner', default = None, help = 'Destination file owner'
)
parser.add_argument(
'-g', '--group', default = None, help = 'Destination file group'
)
parser.add_argument(
'-m', '--mode', default = None, help = 'Destination file mode'
)
parser.add_argument(
'-F',
'--fixed-strings',
action = 'store_true',
help = "Don't expand macros in <src> and <dst>",
)
@override
async def _run(self, args: Namespace) -> None:
def __expand(url: str) -> str:
if args.fixed_strings:
return url
ret = self.app.distro.expand_macros(url)
if not isinstance(ret, str):
raise Exception(
f'Expanding macros in "{url}" returned unexpected ret "{ret}"'
)
return ret
await copy(
__expand(args.src),
__expand(args.dst),
owner = args.owner,
group = args.group,
mode = int(args.mode, 0),
)