Skip to content
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

[FEATURE REQUEST] Blending and ignore #720

Closed
sbrunner opened this issue Jan 27, 2025 · 3 comments · Fixed by #722
Closed

[FEATURE REQUEST] Blending and ignore #720

sbrunner opened this issue Jan 27, 2025 · 3 comments · Fixed by #722

Comments

@sbrunner
Copy link
Member

sbrunner commented Jan 27, 2025

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.

@sbrunner
Copy link
Member Author

@Pierre-Sassoulas, @carlio What do you think about this?

@Pierre-Sassoulas
Copy link
Collaborator

It's probably going to be really painful to maintain, no ? (Check can be similar but not identical). But the feature would be amazing for sure.

@sbrunner
Copy link
Member Author

The blender_combinations.yaml file can be painful to maintain, but he is already here.

What the behavior if the checks are similar but not identical, and we are on the “different” part:

  • When the runs Prospector without any ignore => we get only the check who is triggered.
  • When we ignore one of them => we will not have any issue reported.

For me, it's a coherent behavior :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants