Due to the number of changes, I'm keeping this PR to automated changes only. Ran using ruff check adodbapi --select=UP031,UP032 --fix --unsafe-fixes then black . (Ruff re-implements pyupgrade and is configurable)
In Python 3.1 and later, format strings can use implicit positional references. For example, "{0}, {1}".format("Hello", "World") can be rewritten as "{}, {}".format("Hello", "World").
If the positional indices appear exactly in-order, they can be omitted in favor of automatic indices to improve readability.
printf-style string formatting has a number of quirks, and leads to less readable code than using str.format calls or f-strings. In general, prefer the newer str.format and f-strings constructs over printf-style string formatting.
Note The formatting operations described here exhibit a variety of quirks that lead to a number of common errors (such as failing to display tuples and dictionaries correctly). Using the newer formatted string literals, the str.format() interface, or template strings may help avoid these errors. Each of these alternatives provides their own trade-offs and benefits of simplicity, flexibility, and/or extensibility.
Extracted from https://github.com/mhammond/pywin32/pull/2094
The adodbapi version of https://github.com/mhammond/pywin32/pull/2122 Prefer "f-strings" (
f"{str}"
) >str.format("")
> "printf
-style" ("%s" % str
)Due to the number of changes, I'm keeping this PR to automated changes only. Ran using
ruff check adodbapi --select=UP031,UP032 --fix --unsafe-fixes
thenblack .
(Ruff re-implements pyupgrade and is configurable)https://docs.astral.sh/ruff/rules/format-literals/#why-is-this-bad
https://docs.astral.sh/ruff/rules/printf-string-formatting/#why-is-this-bad
https://docs.astral.sh/ruff/rules/f-string/#why-is-this-bad
https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting