-
Notifications
You must be signed in to change notification settings - Fork 278
Use lazy (old style %-format) log formatting in the new pylint config #1334
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
Comments
An example approach to avoid the warnings while using f-strings which feels more like a workaround: 438c0a0 |
It's annoying to use a different formatting method for logging than anything else but the reasoning is solid... Most of our logging is not in a "hot loop" but some debug logs really might be used quite a lot (and the workaround only hides the warning, not the potential performance issue in those cases). I think using %-style is fine for logging: |
And then there is this issue when trying to use %-style formatting but you've set up |
I had understood that using %-style implies means we would need to use |
Disable pylint's "Use lazy % formatting in logging functions" warning until a common logging approach is decided. See theupdateframework#1334. Signed-off-by: Teodora Sechkova <[email protected]>
I'm proposing we use the default logging style, meaning:
It looks a bit uglier (other string formatting is f-strings but logging is then based on %-formatting) but:
|
Proposal above makes sense to me, if it's what's suggested by the style guide we probably don't even need to capture anything for this? Let's just do what our style guide suggests. |
This is suggested by the Google style guide: the old style logging (%-format) allows the log strings to be lazily formatted so there's less need to think about performance when forming debug messages. No actual code changes are needed because the metadata API does not yet log anything. Fixes theupdateframework#1334 Signed-off-by: Jussi Kukkonen <[email protected]>
Description of issue or feature request:
Using f-strings (and all types of string formatting except %-syle) in logging messages is not lazy evaluated so linters "recommend" %-style formatting.
Should we disable the related pylint warnings and use f-strings:
or adhere to the recommendation.
Current behavior:
Top-level
pylintrc
disables logging that recommend lazy formatting globally.New
api/pylintrc
does not.Expected behavior:
Decide on a common approach.
The text was updated successfully, but these errors were encountered: