question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use lazy (old style %-format) log formatting in the new pylint config

See original GitHub issue

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:

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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jkucommented, May 7, 2021

I’m proposing we use the default logging style, meaning:

  • use logging-format-style=old (which is default value)
  • stop disabling 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:

  • it’s a common style
  • it’s suggested by the google style guide
  • it means we don’t have to think about performance when writing logging code
1reaction
joshuaglcommented, May 10, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found