Skip to content

consider-using-f-string and logging-fstring-interpolation are mutually exclusive #5286

@angiarao

Description

@angiarao

Bug description

Enabling both C0209 (consider-using-f-string) and W1203(logging-fstring-interpolation) causes conflict issues.
If logging is using % formatting, then C0209 error message is throwing on the logging string. Is there a way to avoid this conflict?

Configuration

# Maximum number of nested blocks for function / method body
max-nested-blocks=5

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# Example:
# disable=E1608,W1627,E1601
# we are disabling all warnings as it would create a lot of noise
# we will enable only selected warnings when needed.
disable=all

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time. See also the "--disable" option for examples.
# List of all codes can be found here -
# https://pylint.pycqa.org/en/latest/technical_reference/features.html
# or http://pylint-messages.wikidot.com/all-codes


enable=C0114,C0206,C0209
    ,E0102,E1111,E1120,E1121,E1123,E1305,E1606,E1601
    ,E9004,E9005,E9006,E9007,E9008,E9009,E9010,E9011
    ,E9013,E9014,E9015,E9016
    ,R0912,R1702,R1734
    ,W0101,W0123,W0311,W0612,W0613,W0614,W1620
    ,W9001,W9002,W9003,W9017

Command used

python3 -m pylint --rcfile=.py3lintrc --reports=no --msg-template="{line}|{column}|{msg_id}|{symbol}|{msg}" <filename>

Pylint output

Advice  (C0209) pylint - Consider Using F String
Formatting a regular string which could be a f-string
>>>       62     log.debug('resource %s was discovered' % name)

Warning  (W1203) pylint - Logging Fstring Interpolation
Use lazy % or .format() or % formatting in logging functions
>>>       62     log.debug(f'resource {name} was discovered')

Expected behavior

i think C0209 should be suppressed if the W1203 is enabled.

Pylint version

pylint 2.11.1
astroid 2.8.4
Python 3.6.9 (default, Jan 26 2021, 15:33:00)
[GCC 8.4.0]

OS / Environment

Ubuntu 18.04

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentation 📗Enhancement ✨Improvement to a componentGood first issueFriendly and approachable by new contributorsHacktoberfestHelp wanted 🙏Outside help would be appreciated, good for new contributorsNeeds 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