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

@@ -92,9 +92,9 @@ def repo_comment_handler(
repo_name = payload["repository"]["name"].tame(check_string)
topic_name = BITBUCKET_TOPIC_TEMPLATE.format(repository_name=repo_name)
sha = payload["commit"].tame(check_string)
commit_url = payload["repository"]["links"]["self"][0]["href"].tame(check_string)[
: -len("browse")
]
commit_url = (
payload["repository"]["links"]["self"][0]["href"].tame(check_string).removesuffix("browse")
)
commit_url += f"commits/{sha}"
message = payload["comment"]["text"].tame(check_string)
if action == "deleted their comment":