python: Simplify with str.removeprefix, str.removesuffix.

These are available in Python ≥ 3.9.
https://docs.python.org/3/library/stdtypes.html#str.removeprefix

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-09-03 10:42:14 -07:00
committed by Tim Abbott
parent 1ec4539550
commit 91ade25ba3
42 changed files with 79 additions and 92 deletions

View File

@@ -294,7 +294,7 @@ def get_topic_resolution_and_bare_name(stored_name: str) -> tuple[bool, str]:
- The topic name with the resolution prefix, if present in stored_name, removed
"""
if stored_name.startswith(RESOLVED_TOPIC_PREFIX):
return (True, stored_name[len(RESOLVED_TOPIC_PREFIX) :])
return (True, stored_name.removeprefix(RESOLVED_TOPIC_PREFIX))
return (False, stored_name)