Skip to content

Commit

Permalink
style: Fix FURB188: Prefer removeprefix over conditionally replacin…
Browse files Browse the repository at this point in the history
…g with slice.

Ruff rule: https://docs.astral.sh/ruff/rules/slice-to-remove-prefix-or-suffix/

This is a new rule introduced in ruff 0.6.5
  • Loading branch information
echoix committed Sep 15, 2024
1 parent e7099b3 commit 544e6de
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
3 changes: 1 addition & 2 deletions man/parser_standard_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def split_opt_line(line):
index = line.index("=")
key = line[:index].strip()
default = line[index + 1 :].strip()
if default.startswith("_("):
default = default[2:]
default = default.removeprefix("_(")
return key, default

def parse_glines(glines):
Expand Down
6 changes: 2 additions & 4 deletions python/grass/gunittest/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ def get_svn_revision():
rc = p.poll()
if not rc:
stdout = stdout.strip()
if stdout.endswith("M"):
stdout = stdout[:-1]
stdout = stdout.removesuffix("M")
if ":" in stdout:
# the first one is the one of source code
stdout = stdout.split(":")[0]
Expand Down Expand Up @@ -211,8 +210,7 @@ def get_svn_info():
if relurl is not None:
relurl = relurl.text
# relative path has ^ at the beginning in SVN version 1.8.8
if relurl.startswith("^"):
relurl = relurl[1:]
relurl = relurl.removeprefix("^")
else:
# SVN version 1.8.8 supports relative-url but older do not
# so, get relative part from absolute URL
Expand Down
4 changes: 1 addition & 3 deletions utils/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ def print_category(category, changes, file=None):
# Relies on author being specified as username.
if " " in author:
author = author.split(" ", maxsplit=1)[0]
if author.startswith("@"):
# We expect that to be always the case, but we test anyway.
author = author[1:]
author = author.removeprefix("@")
if author in known_bot_names or author.endswith("[bot]"):
hidden.append(item)
elif len(visible) > max_section_length:
Expand Down

0 comments on commit 544e6de

Please sign in to comment.