Clan-app/api: error on {unknown api method, mismatching parameter name}

This commit is contained in:
Johannes Kirschbauer
2024-11-28 16:29:57 +01:00
parent c35b30a447
commit d3be596c77

View File

@@ -228,8 +228,17 @@ API.register(open_file)
from inspect import signature
func = self._registry.get(method_name, None)
if func:
if not func:
msg = f"API Method {method_name} not found in registry. Available methods: {list(self._registry.keys())}"
raise ClanError(msg)
sig = signature(func)
# seems direct 'key in dict' doesnt work here
if arg_name not in sig.parameters.keys(): # noqa: SIM118
msg = f"Argument {arg_name} not found in api method '{method_name}'. Avilable arguments: {list(sig.parameters.keys())}"
raise ClanError(msg)
param = sig.parameters.get(arg_name)
if param:
param_class = param.annotation