Skip to content

adodbapi: prefer f-string > format > printf-style autofixes#2241

Draft
Avasam wants to merge 15 commits intomhammond:mainfrom
Avasam:adodbapi-string-formats
Draft

adodbapi: prefer f-string > format > printf-style autofixes#2241
Avasam wants to merge 15 commits intomhammond:mainfrom
Avasam:adodbapi-string-formats

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Apr 10, 2024

Extracted from #2094

The adodbapi version of #2122
Prefer "f-strings" (f"{str}") > str.format("") > "printf-style" ("%s" % str)

Ran using ruff check adodbapi --select=UP031,UP032 --fix --unsafe-fixes && ruff format

https://docs.astral.sh/ruff/rules/format-literals/#why-is-this-bad

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.

https://docs.astral.sh/ruff/rules/printf-string-formatting/#why-is-this-bad

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.

https://docs.astral.sh/ruff/rules/f-string/#why-is-this-bad

f-strings are more readable and generally preferred over str.format calls.

https://docs.python.org/3/library/stdtypes.html#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.

@Avasam Avasam requested a review from vernondcole April 10, 2024 04:53
@Avasam Avasam force-pushed the adodbapi-string-formats branch from 27a182c to e09644f Compare April 10, 2024 04:55
@Avasam Avasam force-pushed the adodbapi-string-formats branch from 5532e4d to 364c2b4 Compare June 1, 2024 19:39
Comment thread ruff.toml Outdated
@Avasam Avasam marked this pull request as draft December 4, 2025 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant