Read the vulture configuration from pyproject.toml - #836
Conversation
Pierre-Sassoulas
left a comment
There was a problem hiding this comment.
Thank you for working on prospector. Shouldn't we rather use / pass as argument the whole vulture config and not those two values only ?
|
Happy to - but passing the whole config through isn't quite a drop-in, so let me lay out what's actually in it and you can tell me which shape you want.
Of those remaining five, four collide with prospector rather than extend it:
On the plumbing itself, either works for me:
(1) is less to change when vulture grows an option; (2) makes it obvious at a glance which options prospector actually honours, which matters here because four of them are deliberately ignored. I slightly prefer (2) plus a comment naming the ignored keys and why, but I'll do (1) if you'd rather. Which do you want? |
The previous test asserted on the configuration the tool had parsed. This one runs the tool against a fixture project that carries a real [tool.vulture] section, so the assertion is on prospector's own output -- the thing issue prospector-dev#505 is actually about. It also widens the case: ignore_names as well as ignore_decorators, with a genuinely dead function left in the fixture as a control, so the test fails if the section is dropped and equally if it is applied too broadly. Signed-off-by: Eljees <3.14hell@gmail.com>
|
I've replaced the test with a fixture project that runs the tool end to end ( Apologies for the noise of #838 — I opened it as a second attempt at the same issue instead of pushing here, and have closed it. Still on your side: whether prospector should pass vulture's whole config rather than these two keys. My reading of what that involves is in the comment above — short version is that |
The fixture project added in the previous commit is deliberately written the way a small app is written -- unannotated defs, decorator arguments the decorator does not use -- because that is what vulture has to see. Running prospector's own veryhigh profile over it therefore reports 8 messages and fails both the pre-commit hook and the "Run Prospector checks" step, which runs before pytest, so the test suite never executes. Every other tool fixture in the tree is exempted the same way, including the sibling tests/tools/*/testpath/*, which contains the identical unannotated defs. This adds the one missing pattern; nothing else changes. The test is unaffected: it builds ProspectorConfig(workdir=<fixture dir>) and prospector only looks for a profile directly in workdir (prospector/config/__init__.py), so the repository profile is never loaded there. Signed-off-by: Eljees <3.14hell@gmail.com>
|
The five failing jobs were prospector linting its own new test fixture: the fixture is deliberately unannotated, with a decorator argument the decorator does not use, because that is what vulture has to see. The "Run Prospector checks" step runs before pytest, so the suite never got to run either. 83cbf4b adds that fixture directory to The workflows for that commit are currently |
Signed-off-by: Eljees <3.14hell@gmail.com>
Signed-off-by: Eljees <3.14hell@gmail.com>
|
Implemented the whole-config plumbing in ad20945: |
Fixes #505 (and covers what #398 asks for).
VultureTool.configure()only read the disabled message codes; the[tool.vulture]sectionof
pyproject.tomlwas never looked at, soignore_names/ignore_decoratorswere silentlydropped and prospector reported dead code that plain
vulturedoes not:The configuration is now read with vulture's own
vulture.config.make_config(), so the exactsame parsing rules apply, and the file is reported in the
External Config:header like thepylint/pycodestyle tools already do. It is only read when external config is enabled, so
--no-external-configstill ignores it. A malformed[tool.vulture]section is reported as aconfig problem instead of being swallowed.
Added
tests/tools/vulture/test_vulture_config.pywith the case above plus a control test thatthe same code is still reported when the configuration does not ignore it.