-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Bug 🪲False Negative 🦋No message is emitted but something is wrong with the codeNo message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHacktoberfestHelp wanted 🙏Outside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
Bug description
Two issues with bad-string-format-type
:
- Just like
bad-format-character
thebad-string-format-type
message is currently only raised for old-style string formatting. - If only a single value needs to be formatted, the check does not work if the value to format is passed in as a variable. Using variables in tuples however is fine.
Given a file a.py
:
# pylint: disable=consider-using-f-string,missing-module-docstring
WORD = "abc"
print("%d" % "abc") # works
print("%d %d" % (WORD, 1)) # works
print("%d", WORD) # doesn't work
print("{:d}".format("abc")) # doesn't work
print(f"{'abc':d}") # doesn't work
Configuration
``pylintrc`` from ``pylint`` git repo.
Command used
pylint a.py
Pylint output
************* Module a
.notes/a.py:3:6: E1307: Argument 'builtins.str' does not match format type 'd' (bad-string-format-type)
.notes/a.py:4:6: E1307: Argument 'builtins.str' does not match format type 'd' (bad-string-format-type)
Expected behavior
All of the examples should raise the message.
Pylint version
pylint 2.14.0-dev0
astroid 2.11.2
Python 3.10.2 (main, Apr 3 2022, 14:46:07) [Clang 12.0.5 (clang-1205.0.22.9)]
OS / Environment
macOS BigSur 11.6
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
Bug 🪲False Negative 🦋No message is emitted but something is wrong with the codeNo message is emitted but something is wrong with the codeGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHacktoberfestHelp wanted 🙏Outside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation