-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Question
The logging-fstring-interpolation (W1203) warning reads:
| Use % formatting in logging functions and pass the % parameters as arguments
Used when a logging statement has a call form of "logging.<logging method>
(format_string.format(format_args...))". Such calls should use % formatting instead,
but leave interpolation to the logging function by passing the parameters as arguments.
This message is emitted if f-string was used, and it can be disabled if you like.
It's not clear to me from that paragraph if its recommended to still use the formatting operator in logging statements, or if f-strings should be used. My understanding is the original intent of W1203 was to prefer the formatting operator over calls to format() as then the string interpolation is done lazily. I'm guessing the same is true with f-strings correct? Ie F-strings would not be evaluated lazily, so the same reasons for preferring the formatting operator over .format() with log statements apply, and as such the same warning is emitted when f-strings are used with log statements.
Is that correct?
DavidEnergie and metov
Metadata
Metadata
Assignees
Labels
No labels