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

Floating point logging format gives false error #9118

Open
ebbek opened this issue Oct 5, 2023 · 2 comments · May be fixed by #9121
Open

Floating point logging format gives false error #9118

ebbek opened this issue Oct 5, 2023 · 2 comments · May be fixed by #9121
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@ebbek
Copy link

ebbek commented Oct 5, 2023

Bug description

Pylint issues the error logging-too-many-args for the following file (named logerr.py:

#! /usr/bin/env python3
"""
Demonstrate wrong message from pylint
"""
import logging
logging.warning( "The frequency is: %f MHz", 2.3 )

Configuration

[LOGGING]
logging-format-style=new

Command used

pylint logerr.py

Pylint output

************* Module logerr
logerr.py:8:0: E1205: Too many arguments for logging format string (logging-too-many-args)

Expected behavior

No errors.

Pylint version

pylint 3.0.0
astroid 3.0.0
Python 3.11.6 (tags/v3.11.6:8b6ee5b, Oct  2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]

OS / Environment

Windows 11

@ebbek ebbek added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 5, 2023
@nickdrozd
Copy link
Collaborator

Is this a Windows thing? I'm not getting any errors on Ubuntu.

@nickdrozd nickdrozd added Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 5, 2023
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Oct 5, 2023
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Oct 5, 2023

To reproduce you also need:

[LOGGING]
logging-format-style=new

The new style is about {} style formatting and the old style %f so pylint is confused about the old style being used when the new style is declared.

It seems

logging.warning( "The frequency is: {:.2f} MHz", 2.3 )

also raises a false positive with

[LOGGING]
logging-format-style=old

Opened #9121

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs reproduction 🔍 Need a way to reproduce it locally on a maintainer's machine labels Oct 5, 2023
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Oct 5, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.0.3 milestone Nov 26, 2023
@Pierre-Sassoulas Pierre-Sassoulas self-assigned this Nov 26, 2023
@jacobtylerwalls jacobtylerwalls modified the milestones: 3.0.3, 3.0.4 Dec 11, 2023
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 3.0.4, 3.1.1 Feb 23, 2024
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 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.

4 participants