CLI: api.register type preservation
This commit is contained in:
committed by
kenji
parent
f3a9a4e108
commit
dc57c3d948
@@ -107,7 +107,9 @@ API.register(open_file)
|
||||
self.register(wrapper)
|
||||
return fn
|
||||
|
||||
def register(self, fn: Callable[..., T]) -> Callable[..., T]:
|
||||
F = TypeVar("F", bound=Callable[..., Any])
|
||||
|
||||
def register(self, fn: F) -> F:
|
||||
if fn.__name__ in self._registry:
|
||||
msg = f"Function {fn.__name__} already registered"
|
||||
raise ClanError(msg)
|
||||
|
||||
@@ -68,7 +68,7 @@ def create_clan(options: CreateOptions) -> CreateClanResponse:
|
||||
)
|
||||
|
||||
if options.initial:
|
||||
init_inventory(options.directory, init=options.initial)
|
||||
init_inventory(str(options.directory), init=options.initial)
|
||||
|
||||
response = CreateClanResponse(
|
||||
flake_init=flake_init,
|
||||
|
||||
@@ -198,7 +198,7 @@ def generate_machine_hardware_info(
|
||||
f"HW/report: Hardware configuration for {machine_name}",
|
||||
)
|
||||
try:
|
||||
show_machine_hardware_platform(clan_dir, machine_name)
|
||||
show_machine_hardware_platform(clan_dir.path, machine_name)
|
||||
except ClanCmdError as e:
|
||||
log.exception("Failed to evaluate hardware-configuration.nix")
|
||||
# Restore the backup file
|
||||
@@ -235,7 +235,7 @@ def hw_generate_command(args: argparse.Namespace) -> None:
|
||||
force=args.force,
|
||||
)
|
||||
hw_info = generate_machine_hardware_info(
|
||||
opts.flake, opts.machine, opts.target_host, opts.password, opts.force
|
||||
opts.flake, opts.machine, opts.target_host, opts.password
|
||||
)
|
||||
print("Successfully generated hardware information.")
|
||||
print(f"Target: {opts.machine} ({opts.target_host})")
|
||||
|
||||
@@ -24,7 +24,7 @@ from helpers import cli
|
||||
@pytest.mark.with_core
|
||||
def test_list_modules(test_flake_with_core: FlakeForTest) -> None:
|
||||
base_path = test_flake_with_core.path
|
||||
modules_info = list_modules(base_path)
|
||||
modules_info = list_modules(str(base_path))
|
||||
|
||||
assert len(modules_info.items()) > 1
|
||||
# Random test for those two modules
|
||||
|
||||
Reference in New Issue
Block a user