Skip to content

Commit

Permalink
style: Call startswith once with a tuple (PIE810)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Sep 19, 2024
1 parent 333d8e6 commit ef0c059
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/core/toolboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def module_test():

someDiff = False
for line in result:
if line.startswith("+") or line.startswith("-"):
if line.startswith(("+", "-")):
sys.stdout.write(line)
someDiff = True
if someDiff:
Expand Down
6 changes: 1 addition & 5 deletions gui/wxpython/psmap/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,11 +1936,7 @@ def Read(self, instruction, text, **kwargs):
instr = {}

for line in text:
if (
line.startswith("vpoints")
or line.startswith("vlines")
or line.startswith("vareas")
):
if line.startswith(("vpoints", "vlines", "vareas")):
# subtype
if line.startswith("vpoints"):
subType = "points"
Expand Down
4 changes: 1 addition & 3 deletions lib/init/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,7 @@ def load_env(grass_env_file):
v = v.strip('"')
# we'll keep expand=True to expand $var's inside "value" because
# they are within double quotes
elif (
v.startswith("'") or v.endswith("'") or v.startswith('"') or v.endswith('"')
):
elif v.startswith(("'", '"')) or v.endswith(("'", '"')):
# here, let's try to ignore unmatching single/double quotes, which
# might be a multi-line variable or just a user error
debug("Ignoring multi-line environmental variable {0}".format(k))
Expand Down
4 changes: 1 addition & 3 deletions man/build_class_graphical.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def starts_with_module(string, module) -> bool:
# module = module.replace('wxGUI.', 'g.gui.')
# TODO: matches g.mapsets images for g.mapset and d.rast.num for d.rast
return bool(
string.startswith(module.replace(".", "_"))
or string.startswith(module.replace(".", ""))
or string.startswith(module)
string.startswith((module.replace(".", "_"), module.replace(".", ""), module))
)


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ ignore = [
"PERF403", # manual-dict-comprehension
"PIE794", # duplicate-class-field-definition
"PIE808", # unnecessary-range-start
"PIE810", # multiple-starts-ends-with
"PLC0415", # import-outside-top-level
"PLC1901", # compare-to-empty-string
"PLC2701", # import-private-name
Expand Down
2 changes: 1 addition & 1 deletion utils/generate_release_notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def notes_from_gh_api(start_tag, end_tag, branch, categories, exclude):
raw_changes = lines[start_whats_changed + 1 : end_whats_changed]
changes = []
for change in raw_changes:
if change.startswith("* ") or change.startswith("- "):
if change.startswith(("* ", "- ")):
changes.append(change[2:])
else:
changes.append(change)
Expand Down
2 changes: 1 addition & 1 deletion utils/gitlog2changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
except Exception as e:
print(f"Could not parse dateList = '{line}'. Error: {e!s}")
# The Fossil-IDs are ignored:
elif line.startswith(" Fossil-ID:") or line.startswith(" [[SVN:"):
elif line.startswith((" Fossil-ID:", " [[SVN:")):
continue
# The svn-id lines are ignored
elif " git-svn-id:" in line:
Expand Down

0 comments on commit ef0c059

Please sign in to comment.