From 17f3d2d58135b94b843b38c95fa54c99b2796b9f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Jul 2021 08:44:50 +0530 Subject: [PATCH] DRYer --- kitty/cli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kitty/cli.py b/kitty/cli.py index a9fcc9e3f..3bfeda8e2 100644 --- a/kitty/cli.py +++ b/kitty/cli.py @@ -224,12 +224,12 @@ def parse_option_spec(spec: Optional[str] = None) -> Tuple[OptionSpecSeq, Option def prettify(text: str) -> str: + def identity(x: str) -> str: + return x + def sub(m: Match) -> str: role, text = m.group(1, 2) - try: - return str(role_map[role](text)) - except KeyError: - return str(text) + return role_map.get(role, identity)(text) text = re.sub(r':([a-z]+):`([^`]+)`', sub, text) return text