summaryrefslogtreecommitdiffstats
path: root/anta/cli/debug/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'anta/cli/debug/utils.py')
-rw-r--r--anta/cli/debug/utils.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/anta/cli/debug/utils.py b/anta/cli/debug/utils.py
index a4bb5d9..26fef45 100644
--- a/anta/cli/debug/utils.py
+++ b/anta/cli/debug/utils.py
@@ -51,11 +51,8 @@ def debug_options(f: Callable[..., Any]) -> Callable[..., Any]:
# TODO: @gmuloc - tags come from context https://github.com/arista-netdevops-community/anta/issues/584
# pylint: disable=unused-argument
# ruff: noqa: ARG001
- try:
- d = inventory[device]
- except KeyError as e:
- message = f"Device {device} does not exist in Inventory"
- logger.error(e, message)
+ if (d := inventory.get(device)) is None:
+ logger.error("Device '%s' does not exist in Inventory", device)
ctx.exit(ExitCode.USAGE_ERROR)
return f(*args, device=d, **kwargs)