Skip to content

Replace all old-style %r string formatting#2278

Open
Avasam wants to merge 9 commits intomhammond:mainfrom
Avasam:replace-old-style-%r
Open

Replace all old-style %r string formatting#2278
Avasam wants to merge 9 commits intomhammond:mainfrom
Avasam:replace-old-style-%r

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Jun 4, 2024

Follow-up to #2122

This replaces all usages of %r for string formatting with newer style {!r}. Excluding adodbapi

References:

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.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 mhammond June 4, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant