From ddc037fa336996e887278c0bbc806146682b7402 Mon Sep 17 00:00:00 2001 From: David Runge Date: Mon, 29 May 2023 13:09:32 +0200 Subject: [PATCH] Simplify trust_color() using match statement --- libkeyringctl/trust.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libkeyringctl/trust.py b/libkeyringctl/trust.py index 7911b60..67ea0ed 100644 --- a/libkeyringctl/trust.py +++ b/libkeyringctl/trust.py @@ -224,16 +224,13 @@ def trust_color(trust: Trust) -> Color: ------- The color representing the passed trust status """ - color: Color = Color.RED - if trust == Trust.revoked: - color = Color.RED - if trust == Trust.unknown: - color = Color.YELLOW - if trust == Trust.marginal: - color = Color.YELLOW - if trust == Trust.full: - color = Color.GREEN - return color + match trust: + case Trust.full: + return Color.GREEN + case Trust.unknown | Trust.marginal: + return Color.YELLOW + case _: + return Color.RED def format_trust_label(trust: Trust) -> str: