Skip to content

bad-format-character false negative on .format() and f-strings #6085

Open
@DudeNr33

Description

@DudeNr33

Bug description

bad-format-character is not raised for new-style string formatting and f-strings.

# pylint: disable=consider-using-f-string, missing-module-docstring
PI = 3.1415
print("Pi is %.2v" % PI)
print("Pi is {:.2v}".format(PI))
print(f"Pi is {PI:.2v}")

Configuration

No response

Command used

pylint a.py

Pylint output

************* Module a
a.py:3:6: E1300: Unsupported format character 'v' (0x76) at index 9 (bad-format-character)

Expected behavior

bad-format-character is currently only emitted for the old-style string formatting.

It should also cover new style formatting and f-strings.

Pylint version

pylint 2.14.0-dev0
astroid 2.11.2
Python 3.9.6 (default, Jul 28 2021, 21:15:06) 
[Clang 12.0.5 (clang-1205.0.22.9)]

OS / Environment

macOS Big Sur Version 11.6

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    False Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions