Skip to content

Pylint does not escape strings before outputting them in messages #7874

@GideonBear

Description

@GideonBear

Bug description

var == '\n'

I confirmed this happens in magic-value, but I don't know if there are other errors that this can apply to.
Maybe it should use repr instead of str for representing values?
This also happens with other characters:

  • '\r': '. (magic-value-comparison) R2004: Consider using a named constant or an enum instead of '
  • Any color code (for example '\033[92m'): Everything after instead of ' is colored green

Configuration

[MAIN]
load-plugins=pylint.extensions.magic_value

Command used

pylint a.py

Pylint output

R2004: Consider using a named constant or an enum instead of '
'. (magic-value-comparison)

Expected behavior

R2004: Consider using a named constant or an enum instead of '\n'. (magic-value-comparison)

Pylint version

pylint 2.16.0-dev
astroid 2.12.13
Python 3.9.15 (main, Nov 11 2022, 13:33:56) 
[GCC 9.4.0]

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🪲Needs 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