Simplify trust_color() using match statement

This commit is contained in:
David Runge 2023-05-29 13:09:32 +02:00
parent f6d2b35318
commit ddc037fa33
No known key found for this signature in database
GPG Key ID: 139B09DA5BF0D338

View File

@ -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: