mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
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:
committed by
Tim Abbott
parent
1ec4539550
commit
91ade25ba3
@@ -78,7 +78,7 @@ def get_or_create_key_prefix() -> str:
|
||||
tries = 1
|
||||
while tries < 10:
|
||||
with open(filename) as f:
|
||||
prefix = f.readline()[:-1]
|
||||
prefix = f.readline().removesuffix("\n")
|
||||
if len(prefix) == 33:
|
||||
break
|
||||
tries += 1
|
||||
@@ -214,7 +214,7 @@ def cache_get_many(keys: list[str], cache_name: str | None = None) -> dict[str,
|
||||
remote_cache_stats_start()
|
||||
ret = get_cache_backend(cache_name).get_many(keys)
|
||||
remote_cache_stats_finish()
|
||||
return {key[len(KEY_PREFIX) :]: value for key, value in ret.items()}
|
||||
return {key.removeprefix(KEY_PREFIX): value for key, value in ret.items()}
|
||||
|
||||
|
||||
def safe_cache_get_many(keys: list[str], cache_name: str | None = None) -> dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user