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

Add violation codes that can be ignored #265

Open
jamilraichouni opened this issue Oct 7, 2021 · 4 comments
Open

Add violation codes that can be ignored #265

jamilraichouni opened this issue Oct 7, 2021 · 4 comments

Comments

@jamilraichouni
Copy link

jamilraichouni commented Oct 7, 2021

I combine flake8 and vulture and want to use vulture for stuff that is not being found by flake8.
The issue is that there are cases where I get two problems reported for one and the same issue in the code.

Example:

def main(a: int):
    """Do something useful."""
    b: int = 2 * CONST
    return b

Here flake8 including the plugin (flake8-unused-arguments) reports an unused argument and vulture also reports the same unused variable with 100% confidence.

It would be great to be able to fine-tune that like it is possible for flake8 (e. g. in the tox.ini) via stuff like that:

[flake8]
ignore =
	D211,  ; ignore "No blank lines allowed before class docstring" AND prefer D203 "1 blank line required before class docstring"
	D213,  ; ignore "Multi-line docstring summary should start at the second line"
	D402,  ; ignore "First line should not be the function’s “signature”"
	D415,  ; ignore "First line should end with a period, question mark, or exclamation point" AND prefer D400 "First line should end with a period"
	F721,  ; ignore "syntax error in doctest"
	W503,  ; ignore "line break before binary operator" according to black formatting

Hence, you may want to introduce violation codes that can be ignored in the pyproject.toml. For instance:

[tool.vulture]
ignore = ["V123",]

Many thanks!
Jamil

@dsuch
Copy link

dsuch commented Dec 15, 2021

Yes, this is a very good idea. For serious purposes, one uses at least several static checkers, each good in its own way, and what you suggest would be truly helpful.

@RJ722
Copy link
Contributor

RJ722 commented Dec 20, 2021

Seeing that we already support # noqa for some particular flake8 codes (like F401: module imported but unused and F841: local variable is assigned to but never used), I don't see a reason why we shouldn't support this.

I'll be happy to work out a pull request once we get a confirmation from @jendrikseipp.

@jendrikseipp
Copy link
Owner

I'm not opposed to adding such functionality. However, I'm not yet convinced that such a feature is useful. Your example @jamilraichouni would ignore unused arguments for all functions (assuming that V123 is the code for unused arguments). At the same time, you explicitly add flake8-unused-arguments to catch them. Isn't that a contradiction? Can you post an example where ignoring Vulture error codes would be helpful for you?

@songololo
Copy link

songololo commented Apr 30, 2022

In my case I have a python package with functions made available to end-users, but which I don't necessarily use in my own code. I'd like to be able to ignore unused-function errors and just catch unused-variable errors.

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

No branches or pull requests

5 participants