Disable pylint check logging-fstring-interpolation
globally
#206
Replies: 4 comments 7 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
-
What do you think about keeping these in the sdk, but disabling them in external actors/application code by default. Then users get the freedom to log as they prefer, and don't have to be affected by out decisions. Is it really a big inconvenience to do old style logging? |
Beta Was this translation helpful? Give feedback.
-
NB: I was just running into this in an actor code, where I inherently disagreed with that warning. I am generally for globally disabling this |
Beta Was this translation helpful? Give feedback.
-
I suppose this part here is an argument against f-strings in logs: http://tohyongcheng.github.io/python/2016/02/20/testing-your-logger-in-python-unit-tests.html |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
pylint
warns against using f-strings inlogging
functions because the built-in interpolation provides an optimization: it does not do the interpolation if the message is not emitted. This is inconvenient because f-strings have been the recommended way to do interpolation for a long time now, and having to resort to the old interpolation style means developers need to know 2 ways to interpolate strings, which are very different.Doing a quick search, it looks like the performance gain is really negligible, so I propose to disable the
pylint
checklogging-fstring-interpolation
globally in thepyproject.toml
config and use f-strings instead for logging.For hot paths that need logging (which in general will be a bad idea anyway) we can either use the old interpolation, or better, use
if logger.isEnabledFor(logging.DEBUG):
to avoid the whole call to the logger if it's not going to be logged.Just for completeness, here is a comment mentioning a couple of reasons why using logging interpolation could be good regardless of the performance issue:
Beta Was this translation helpful? Give feedback.
All reactions