-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style: Fix missing-f-string-syntax (RUF027) #5031
base: main
Are you sure you want to change the base?
Conversation
RUF027 Possible f-string without an `f` prefix Ruff rule: https://docs.astral.sh/ruff/rules/missing-f-string-syntax/
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This brings up the larger issue of r.mapcalc syntax in Python. String templates (string.Template) were adopted to be used internally, but it was never mandatory (it can't be) and it was before format function and f-strings and their appeal was closeness to shell/Bash substitution. Having theses RUF ignores here is not nice. It could just switch to f-strings. I'm not sure what to do here in this PR specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can input be safely substituted here without passing the "input" to mapcalc? Otherwise we can keep it as I changed it here, that is to not use an f-string because of the conflict. It's not that bad to say no to a syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it us the same, but on a second thought, this PR is not the place to change the practice.
RUF027 Possible f-string without an
f
prefixRuff rule: https://docs.astral.sh/ruff/rules/missing-f-string-syntax/