Skip to content

[FEATURE REQUEST] Blending and ignore #720

@sbrunner

Description

@sbrunner

Issue

When we ignore a blended message, another one aspires

Create test environment

toto.py:

def main():
    a = 1

.prospector.yaml file:

pylint:
  run: true
  enable:
    - unused-variable
vulture:
  run: true
  enable:
    - unused-variable
pyflakes:
  run: true
  enable:
    - F841

Test blending => OK

prospector --no-blending --output-format=pylint toto.py:

...
toto.py:2: unused-variable(vulture): Unused variable 'a'
toto.py:2:4: [unused-variable(pylint), main]: Unused variable 'a'
toto.py:2:5: F841(pyflakes): local variable 'a' is assigned to but never used
...

prospector --output-format=pylint toto.py:

...
toto.py:2:4: [unused-variable(pylint), main]: Unused variable 'a'
...

=> the blending works correctly

Test Ignore

Ignore the error with # pylint: disable=unused-variable

=>

...
toto.py:2: unused-variable(vulture): Unused variable 'a'
...

=> We get another issue
=> It will be good if it will be completely ignored

Describe the solution you'd like

The solution I imagine:

  • In the tools classes, add a function to parse the lines of code to get the ignored codes. This will be implemented in the Pylint, Mypy and Ruff, the other tolls can't ignore a specific code, and that is necessary for our usage. For Ruff we should be sure that it will not create some issue with other tools.
  • Replace this part of code https://github.com/prospector-dev/prospector/blob/master/prospector/suppression.py#L144-L155 by one that uses the blending configuration and the parsed code by tools to generate the other ignores.

Describe alternatives you've considered

Create a profile that ignores the duplicated check, but it's in the opposition of blending, and the advantage of the proposed solution we are more safe do not ignore a check to replace it by as less safe one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions