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

@@ -54,7 +54,7 @@ def write_updated_configs() -> None:
).strip()
for key, shards in config_file["tornado_sharding"].items():
if key.endswith("_regex"):
ports = [int(port) for port in key[: -len("_regex")].split("_")]
ports = [int(port) for port in key.removesuffix("_regex").split("_")]
shard_regexes.append((shards, ports[0] if len(ports) == 1 else ports))
nginx_sharding_conf_f.write(
f" {nginx_quote('~*' + shards)} http://tornado{'_'.join(map(str, ports))};\n"