klen / pylama

Code audit tool for python.
MIT License
1.05k stars 99 forks source link

Can't configure vulture `min_confidence` in `pyproject.toml` #244

Open syserr0r opened 1 year ago

syserr0r commented 1 year ago

Vulture option under [tool.pylama.linter.vulture] as min_confidence

The following pyproject.toml that has the min-confidence configuration option specified with hyphens as underscores:

[tool.pylama.linter.vulture]
min_confidence = 80

causes the following output/error when pylama is run:

usage: vulture [options] [PATH ...]
vulture: error: unrecognized arguments: --min_confidence=80

Vulture option under [tool.pylama.linter.vulture] as min-confidence

Running instead with with min-confidence as-is appears to show the correct output but is not shown in VSCode (not sure why):

[tool.pylama.linter.vulture]
min-confidence = 80

output:

src/main/helpers.py:10:1 V104 unused import 'Min' (90% confidence) [vulture]
src/main/helpers.py:10:1 V104 unused import 'Q' (90% confidence) [vulture]
src/main/helpers.py:11:1 C0411 standard import "from typing import Union" should be placed before "from django.db.models import Q, Min" [pylint]
src/main/helpers.py:12:1 W0611 'datetime.date' imported but unused [pyflakes]
src/main/helpers.py:12:1 C0411 standard import "from datetime import date, datetime" should be placed before "from django.db.models import Q, Min" [pylint]
src/main/helpers.py:12:1 V104 unused import 'date' (90% confidence) [vulture]
src/main/helpers.py:12:1 V104 unused import 'datetime' (90% confidence) [vulture]
...

Vulture option specified under [tool.vulture] as min_confidence

Running under [tool.vulture] with underscores half works as above, producing output but not registering in VSCode

[tool.vulture]
min_confidence = 80

Vulture option specified under [tool.vulture] as min-confidence

Running under [tool.vulture] with hyphen produces an error

[tool.vulture]
min_confidence = 80

output:

Unknown configuration key: min-confidence

I'm not sure if I'm doing something wrong or have missed some trick, any advice appreciated.

syserr0r commented 1 year ago

Interestingly adjusting the Pylama args in VSCode to include --vulture-min-confidence 80 doesn't stop pylama from working correctly but also doesn't change the output (i.e. I still have warnings with confidence under 80%).

The full command that is run during this is: ~/.virtualenvs/<project-name>/bin/python ~/.vscode-server/extensions/ms-python.python-2023.8.0/pythonFiles/linter.py -m pylama "--vulture-min-confidence 80" ./src/main/helpers.py

Edit: Adding in 2 arguments, --vulture-min-confidence and 80 appears to have done the trick, although this is still a work-around I'd prefer to avoid as it makes keeping settings consistent between projects and team members more difficult. (Nope, I can't reproduce this sadly)