pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Remove module lines in "text" and "parseable" reporter

Open cykerway opened this issue 2 years ago • 4 comments

Any chance we can have an option to remove these module lines from "text" reporter? They are annoying when parsing the messages and require an extra step of filtering. This is also true for the "parseable" reporter. At least make this option available in the "parseable" reporter?

https://github.com/PyCQA/pylint/blob/d29bcf68393b6a1654aa6cd3d5351ed63edb42ad/pylint/reporters/text.py#L198

cykerway avatar Nov 22 '21 05:11 cykerway

There are multiple easily parseable outputs , we're not going to make a breaking change to the output without a really good reason.

Pierre-Sassoulas avatar Nov 22 '21 08:11 Pierre-Sassoulas

There aren't "multiple" easily parseable outputs. The only one I've found easily parseable is the json reporter, which still isn't very easily with command line tools.

However, I found the "parseable" format is going to be deprecated:

https://github.com/PyCQA/pylint/blob/d29bcf68393b6a1654aa6cd3d5351ed63edb42ad/pylint/reporters/text.py#L222

It'd be very easy to keep it useful by overwriting handle_message like:

def handle_message(self, msg: Message) -> None:
    """manage message of different type and in the context of path"""
    self.write_message(msg)

Is that by intention that pylint output is going be parsed in json anyway?

cykerway avatar Nov 22 '21 09:11 cykerway

Is that by intention that pylint output is going be parsed in json anyway?

pylint is already very configurable. Did you try to specify the output you want with --msg-template ?

    --msg-template=<template>
                        Template used to display messages. This is a python
                        new-style format string used to format the message
                        information. See doc for all details.

https://pylint.pycqa.org/en/latest/user_guide/output.html#custom-message-formats

Pierre-Sassoulas avatar Nov 22 '21 09:11 Pierre-Sassoulas

Yes, I know this intra-line formatting is very configurable (and works great), but what I'm asking here is about inter-line formatting. Those extra ************* markers are annoying when parsing pylint output using line-based command line tools. So what I'm doing now is writing:

pylint ... | grep -v '\*\*\*\*\*\*\*\*\*\*\*\*\*'

As you can see this is awkward. If you omit those markers we can save the grep. Given that you are deprecating parseable, maybe keeping it for such use is a better idea.

cykerway avatar Nov 22 '21 11:11 cykerway

@Pierre-Sassoulas is this a very breakable change that we want to wait for 3.0 or are we good to do it now / anytime?

clavedeluna avatar Nov 23 '22 19:11 clavedeluna

I think it's possible to add an option to remove the intraline without touching the default and witohut breaking changes.

Pierre-Sassoulas avatar Nov 23 '22 19:11 Pierre-Sassoulas

@Pierre-Sassoulas what's the right way to add a new configuration options, such as --no-header? I'm looking thru the code and it's confusing, probably because it's streamlined. Is it to add this option to base_options.py? Somewhere else?

Basically so I can do

                if not self.linter.config.no_header:
                    self.writeln(f"************* Module {msg.module}")

clavedeluna avatar Nov 24 '22 20:11 clavedeluna

You can check _make_run_options in pylint.lint.base_options.py, there's pre-processing of some options elsewhere, but I don't think we need pre-processing for this one.

Pierre-Sassoulas avatar Nov 28 '22 21:11 Pierre-Sassoulas