Skip to content
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

Do not use f-strings and preformatted messages in logs. #1480

Closed
Carreau opened this issue Dec 17, 2024 · 3 comments
Closed

Do not use f-strings and preformatted messages in logs. #1480

Carreau opened this issue Dec 17, 2024 · 3 comments
Labels

Comments

@Carreau
Copy link
Contributor

Carreau commented Dec 17, 2024

Prompted by comment in #1478 (comment)

in general you never want to pass anything but a literal string as a first argument go the various log.info|warn|error methods; see https://docs.astral.sh/ruff/rules/#flake8-logging-format-g

That is to say, no f-strings; not even pre-formatted variables, as it prevents formatters to do a lot of what they are supposed to do.

There is at least 2 dozen usage of this pattern in the codebase:

$ grep -r  'log.info(f' .   | wc -l
      26
@Carreau Carreau added the bug label Dec 17, 2024
@krassowski
Copy link
Collaborator

Is this a duplicate of #1186?

@Carreau
Copy link
Contributor Author

Carreau commented Dec 17, 2024

It is indeed.

@Zsailer
Copy link
Member

Zsailer commented Apr 2, 2025

Closing, since it's a duplicate. Thanks!

@Zsailer Zsailer closed this as completed Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants