Use lazy (old style %-format) log formatting in the new pylint config
See original GitHub issueDescription 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:
logging-not-lazy
logging-format-interpolation
logging-fstring-interpolation
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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
PyLint message: logging-format-interpolation - Stack Overflow
[LOGGING] # Format style used to check logging format string. `old` means using % # formatting, `new` is for `{}` formatting,and `fstr` is ......
Read more >logging-format-interpolation / W1202 - Pylint 2.16.0-dev ...
Used when a logging statement has a call form of "logging.<logging method>(format_string.format(format_args...))". Use another type of string formatting instead ...
Read more >W1203: Use lazy % formatting in logging functions (logging ...
Format style used to check logging format string. `old` means using % # formatting, while `new` is for `{}` formatting.
Read more >pylint disable logging-fstring-interpolation
logging -format-style is a new option for the logging checker for usage of str.format() style format strings in calls to loggers. It accepts...
Read more >W1202 (logging-format-interpolation) | pylint-errors
Used when a logging statement has a call form of logging.<logging method>(format_string.format(format_args...)) . Use another type of string formatting ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m proposing we use the default logging style, meaning:
logging-format-style=old
(which is default value)logging-not-lazy
(note: this is done only in some experimental client branches – metadata api itself hasn’t needed this because there’s zero logging so far 😬 )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.