Skip to content
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

False positive for logging-fstring-interpolation #4984

Closed
yegarti opened this issue Sep 9, 2021 · 2 comments · Fixed by #7846
Closed

False positive for logging-fstring-interpolation #4984

yegarti opened this issue Sep 9, 2021 · 2 comments · Fixed by #7846
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@yegarti
Copy link

yegarti commented Sep 9, 2021

Bug description

When using f-string without arguments in a logging message, Pylint would warn me about not using lazy % formatting, even though I do use it.

a.py:

import logging
logging.error(f'Hello %s', 'World!')

output:
ERROR:root:Hello World!

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
a.py:2:0: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
a.py:2:14: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

Report only f-string-without-interpolation

Pylint version

pylint 2.10.2
astroid 2.7.3
Python 3.9.4 (default, Apr 30 2021, 18:51:54) 
[GCC 10.2.0]

OS / Environment

Manjaro Linux, Kernel 5.10

Additional dependencies

No response

@yegarti yegarti added Bug 🪲 Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 9, 2021
@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Sep 9, 2021
@sergeyklay
Copy link

Possible related #5039 (comment)

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Sep 23, 2021

Both error disappear if the f-string-without-interpolation is fixed (logging.error("Hello %s', 'World!') but the logging-fstring-interpolation that is raised with logging.error(f'Hello %s', 'World!') is a false positive.

@Pierre-Sassoulas Pierre-Sassoulas added the Minor 💅 Polishing pylint is always nice label Sep 23, 2021
@Pierre-Sassoulas Pierre-Sassoulas added Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Bug 🪲 labels Jul 2, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.7 milestone Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Minor 💅 Polishing pylint is always nice Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants