prospector icon indicating copy to clipboard operation
prospector copied to clipboard

Inconsistent Error Suppression

Open Kilo59 opened this issue 5 years ago • 7 comments

Error suppression is inconsistent between tools and contrary to what the Error Suppression section of the docs say.

https://prospector.landscape.io/en/master/suppression.html

A comment of noqa is used by pep8 and pyflakes when ignoring all errors on a certain line. If Prospector >encounters a # noqa comment it will suppress any error from any tool including pylint and others such as >dodgy.

pylint

However this does not work when using symbolic pylint names.

# noqa: too-many-locals

mccabe

I can't figure out how to suppress mccabe warnings at all. I've tried # noqa: MC0001 and # noqa: C901 as when used with flake8.

Kilo59 avatar Dec 02 '18 18:12 Kilo59

For pylint you can use # pylint: disable=too-many-locals.

# noqa is overridden in order to silence all the tools where it's set. See: https://prospector.readthedocs.io/en/master/suppression.html#noqa.

To disable mccabe codes you can use its section inside the profile:

mccabe:
  disable:
    - MC0001

chocoelho avatar Dec 22 '18 17:12 chocoelho

Thank you, I understand how to use pylint's own # pylint: disable= to suppress pylint error messages. I meant the issue as more of a feature-request/enhancement.

Personally I think not being able to suppress mccabe error message locally/in-line is a bigger deal. Being able to use symbolic pylint error names with # noqa: would be convenient but not really necessary.

Kilo59 avatar Dec 27 '18 19:12 Kilo59

@Kilo59 got that, I'll work something out :+1:

chocoelho avatar Dec 31 '18 21:12 chocoelho

This seems to work for me now. Maybe things got updated and this issue never got closed?

def foo():  # noqa: MC0001
    ....

jcwilson avatar Dec 14 '20 07:12 jcwilson

@jcwilson That's probably caused by # noqa ignoring all errors, as mentioned in the error suppression page.

It seems to me that currently there are no ways to turn of a specific errors for a line, except pylint which implemented it as # pylint:disable=CODE. Coming as a user of flake8 I tremendously missed flake8's generic error suppression # noqa: CODE. Not sure whether maintainers are interested in such a feature. If so I would be very willing to help adding it.

limouren avatar Feb 20 '22 20:02 limouren

@limouren The way prospector handles supressing errors is here - https://github.com/PyCQA/prospector/blob/master/prospector/suppression.py

The thing is - it doesn't have its own syntax. The code there was trying to say that "if someone has hidden a warning in flake8, then the same error generated by pylint should also be hidden". So in other words, it was trying to hide all messages of a certain type across all tools not just the single tool (eg pylint:disable CODE but also equivalent warnings raised by flake8 and so on).

The thing is, that code hasn't been updated for YEARS, the last commit actually handling the behaviour of hiding errors was in 2015. Pylint, pyflakes etc have moved on a lot.

If you're keen to look into it and update things, I'd gladly review and merge a PR.

The main thing to remember is that the purpose is not to introduce new prospector-specific syntax, but rather to handle supressing the same type of error for all tools.

(Also, https://github.com/PyCQA/prospector/blob/master/prospector/blender.py is where prospector tries to match the same error across tools - eg, "unused variable" has different codes in flake8 and pylint etc but the idea is to only emit one warning as there's no point repeating it)

carlio avatar Feb 20 '22 20:02 carlio

@carlio Thanks a lots for the pointers! I will see if I can get something out over the weekend.

limouren avatar Feb 22 '22 05:02 limouren