Skip to content

Conversation

@neykov
Copy link
Contributor

@neykov neykov commented Jan 29, 2019

Steps

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature or an important bug fix, add a What's New entry in doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Description

The number of arguments was not handled properly, leading to an always successful check. See new tests for specific cases this fixes.

Type of Changes

Type
🐛 Bug fix

Related Issue

# special keywords - out of scope.
return
elif self._format_style == "new":
keys, num_args, manual_pos_arg = utils.parse_format_method_string(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug was that num_args was overwriting the one at line 287, so the number of arguments always matches when using implicit positional placeholders. And never matches when using named arguments.

The changes are just renaming variables + removing the short-circuit for no arguments case above.

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Can you fix the CI failures? It's currently failing due to formatting issues. You can follow the pre-commit recommendations from the documentation (or run black manually over those files): http://pylint.pycqa.org/en/latest/development_guide/contribute.html#repository

@coveralls
Copy link

coveralls commented Feb 12, 2019

Coverage Status

Coverage decreased (-0.09%) to 89.535% when pulling 9c02668 on neykov:logging-new-style-fixes into 7a40b0b on PyCQA:master.

The number of arguments was not handled properly, leading to an always successful check. See new tests for specific cases this fixes.
@neykov
Copy link
Contributor Author

neykov commented Feb 12, 2019

@PCManticore this is good to go.

@PCManticore PCManticore merged commit e4fec97 into pylint-dev:master Feb 13, 2019
@PCManticore
Copy link
Contributor

Thanks a lot @neykov for this PR!

@neykov neykov deleted the logging-new-style-fixes branch February 15, 2019 16:28
Pierre-Sassoulas added a commit that referenced this pull request Mar 30, 2025
…ated too

The original decision was taken in db8b3a4 during implementation with
a different rational ("If no args were supplied, then all format strings
are valid don't check any further.") and was not discussed again when the
comment was updated in #2713. I think the new behavior make sense especially
considering that the primer shows 4 false negative in home-assistant.

Co-authored by: Alex Prabhat Bara <[email protected]>
Pierre-Sassoulas added a commit that referenced this pull request Mar 30, 2025
…ated too

The original decision was taken in db8b3a4 during implementation with
a different rational ("If no args were supplied, then all format strings
are valid don't check any further.") and was not discussed again when the
comment was updated in #2713. I think the new behavior make sense especially
considering that the primer shows 4 false negative in home-assistant.

Co-authored-by: Alex Prabhat Bara <[email protected]>
DanielNoord pushed a commit that referenced this pull request Mar 30, 2025
… at all (#10321)

* [feat] Detect missing formatting args when the string is not interpolated too

The original decision was taken in db8b3a4 during implementation with
a different rational ("If no args were supplied, then all format strings
are valid don't check any further.") and was not discussed again when the
comment was updated in #2713. I think the new behavior make sense especially
considering that the primer shows 4 false negative in home-assistant.

Co-authored-by: Alex Prabhat Bara <[email protected]>

* Fix required because logging are tested elsewhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants