Skip to content

Commit

Permalink
style: Fix missing-f-string-syntax (RUF027)
Browse files Browse the repository at this point in the history
RUF027 Possible f-string without an `f` prefix

Ruff rule: https://docs.astral.sh/ruff/rules/missing-f-string-syntax/
  • Loading branch information
echoix committed Feb 2, 2025
1 parent 09f9235 commit dc086a9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ ignore = [
"RUF012", # mutable-class-default
"RUF015", # unnecessary-iterable-allocation-for-first-element
"RUF019", # unnecessary-key-check
"RUF027", # missing-f-string-syntax
"RUF100", # unused-noqa
"S101", # assert
"S108", # hardcoded-temp-file
Expand Down
4 changes: 3 additions & 1 deletion python/grass/gunittest/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def values_equal(value_a, value_b, precision: float = 0.000001) -> bool:
# in Python 3 None < 3 raises TypeError
precision = float(precision)
if precision < 0:
msg = "precision needs to be greater than or equal to zero: {precision} < 0"
msg = (
f"precision needs to be greater than or equal to zero: {precision} < 0"
)
raise ValueError(msg)
if abs(value_a - value_b) > precision:
return False
Expand Down
8 changes: 4 additions & 4 deletions scripts/db.dropcolumn/db.dropcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ def main():
cmds = [
"BEGIN TRANSACTION",
"CREATE TEMPORARY TABLE ${table}_backup(${coldef})",
"INSERT INTO ${table}_backup SELECT ${colnames} FROM ${table}",
"DROP TABLE ${table}",
"INSERT INTO ${table}_backup SELECT ${colnames} FROM ${table}", # noqa: RUF027
"DROP TABLE ${table}", # noqa: RUF027
"CREATE TABLE ${table}(${coldef})",
"INSERT INTO ${table} SELECT ${colnames} FROM ${table}_backup",
"DROP TABLE ${table}_backup",
"INSERT INTO ${table} SELECT ${colnames} FROM ${table}_backup", # noqa: RUF027
"DROP TABLE ${table}_backup", # noqa: RUF027
"COMMIT",
]
tmpl = string.Template(";\n".join(cmds))
Expand Down
6 changes: 3 additions & 3 deletions scripts/r.rgb/r.rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def main():
expressions = []
maps = []
if red:
expressions.append("%s = r#${input}" % red)
expressions.append("%s = r#${input}" % red) # noqa: RUF027
maps.append(red)
if green:
expressions.append("%s = g#${input}" % green)
expressions.append("%s = g#${input}" % green) # noqa: RUF027
maps.append(green)
if blue:
expressions.append("%s = b#${input}" % blue)
expressions.append("%s = b#${input}" % blue) # noqa: RUF027
maps.append(blue)
expr = ";".join(expressions)
gs.mapcalc(expr, input=input)
Expand Down
10 changes: 5 additions & 5 deletions scripts/v.db.dropcolumn/v.db.dropcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ def main():
cmds = [
"BEGIN TRANSACTION",
"CREATE TEMPORARY TABLE ${table}_backup (${coldef})",
"INSERT INTO ${table}_backup SELECT ${colnames} FROM ${table}",
"DROP TABLE ${table}",
"INSERT INTO ${table}_backup SELECT ${colnames} FROM ${table}", # noqa: RUF027
"DROP TABLE ${table}", # noqa: RUF027
"CREATE TABLE ${table}(${coldef})",
"INSERT INTO ${table} SELECT ${colnames} FROM ${table}_backup",
"CREATE UNIQUE INDEX ${table}_cat ON ${table} (${keycol} )",
"DROP TABLE ${table}_backup",
"INSERT INTO ${table} SELECT ${colnames} FROM ${table}_backup", # noqa: RUF027
"CREATE UNIQUE INDEX ${table}_cat ON ${table} (${keycol} )", # noqa: RUF027
"DROP TABLE ${table}_backup", # noqa: RUF027
"COMMIT",
]
tmpl = string.Template(";\n".join(cmds))
Expand Down
2 changes: 1 addition & 1 deletion scripts/v.in.wfs/v.in.wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def main():
tmp = grass.tempfile()
tmpxml = tmp + ".xml"

grass.debug("The request URL: {wfs_url}")
grass.debug(f"The request URL: {wfs_url}")

# Set user and password if given
if options["username"] and options["password"]:
Expand Down

0 comments on commit dc086a9

Please sign in to comment.