-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Colorized output should not modify msg
objects
#7214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have the exact same issue running gives me :
@tom65536 did you find any workaround ? Notes: It does work with python 2.13.9, but breaking at 2.14.0 |
I stopped using the GitlabCodeClimateReporter plugin. It does not solve the problem but works for me. |
I did not have time to look into this yet, but a reproducer not using |
I can try to create a reproductible example with a custom reporter and custom colorizer. |
Actually, it @tom65536 already describe fully the problem. A simple way to reproduce this is adding "colorized" in the list of formatter for the test "test_multi_format_output" here : formats = ",".join(["json:" + str(json), "text", nop_format, "colorized"]) The rendered json will contain the ansi encoded values :
I never contributed to this project, and the question is now, should colorized modify the output (some reporters rely on the color from colorized) or not ? Feels like any reporter must receive a copy of message, otherwise they could interract between each other ? |
I propose to pass a copy to ensure no reporter can affect another reporter. Don't know, if this affect performance ? |
Bug description
I noticed this problem because I use colorized text output alongside with the pylint-gitlab plugin. I filed an issue there as well, but I agree with the author of the plugin that the bug should be fixed within PyLint.
I use the pylint-gitlab reporter and colorized text output in the same run of pylint (see below). The plugin receives the messages modified by the
ColorizedTextReporter
. This causes an exception (KeyError
) because the plugin receives the ANSI-color-coded category\x1b[1mconvention\x1b[0m
instead of simplyconvention
.The modification happens inside the
handle_message
method:Suggested solution:
As I haven't found a way of controlling the order in which the reporters are processed (the behavior would not be a problem if one could ensure that the
ColorizedTextReporter
is called last), I would suggest that the reporter should be changed to work in a re-entrant manner: TheColorizedTextReporter
should not modify the original fields. It should rather add some extra fields (e.g.colorized_category
) or keep a list of copies of the originalmsg
objects.Configuration
No response
Command used
Pylint output
Expected behavior
ANSI-colored output to the screen plus some generated files (
pylint-codeclimate.json
,index.html
,pylint.txt
)Pylint version
pylint-2.14.x (the problem did not occur with pylint<=3.13.x)
OS / Environment
Tested on Linux and Windows
Additional dependencies
pylint-gitlab=1.0.0
The text was updated successfully, but these errors were encountered: