Skip to content

Honour [tool.vulture] in pyproject.toml - #838

Closed
Eljees wants to merge 1 commit into
prospector-dev:masterfrom
Eljees:fix/505-vulture-pyproject-config
Closed

Honour [tool.vulture] in pyproject.toml#838
Eljees wants to merge 1 commit into
prospector-dev:masterfrom
Eljees:fix/505-vulture-pyproject-config

Conversation

@Eljees

@Eljees Eljees commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #505.

VultureTool never read [tool.vulture], and ProspectorVulture.__init__ called Vulture.__init__(self, verbose=False) — dropping the two keyword arguments vulture accepts for exactly this, ignore_names and ignore_decorators. So the same project answered differently depending on which command ran.

With the reporter's setup — ignore_decorators = ["@app.get", "@app.post"], ignore_names = ["keep_me"], and a file holding two decorated routes, keep_me, and one genuinely dead function:

$ vulture app.py
app.py:2: unused variable 'path' (100% confidence)
app.py:5: unused variable 'path' (100% confidence)
app.py:26: unused function 'truly_unused' (60% confidence)

$ prospector --tool vulture            # before
  Line: 12  vulture: unused-function / Unused function 'read_items'
  Line: 17  vulture: unused-function / Unused function 'create_item'
  Line: 22  vulture: unused-function / Unused function 'keep_me'
  Line: 26  vulture: unused-function / Unused function 'truly_unused'
  ... plus the two unused variables

$ prospector --tool vulture            # after
  Line: 2   vulture: unused-variable / Unused variable 'path'
  Line: 5   vulture: unused-variable / Unused variable 'path'
  Line: 26  vulture: unused-function / Unused function 'truly_unused'

The two now agree.

The section is read with vulture's own make_config, rather than a hand-rolled TOML read, so the two can't drift on what a key means. The argv it's given is only there to satisfy vulture's argument parser, which insists on a path; the paths it produces are discarded, since prospector has already found the files. A missing or malformed pyproject.toml yields no settings rather than an error — prospector runs in plenty of projects that have neither.

Deliberately not included: min_confidence and exclude. Both are in the same section, but prospector does its own file finding and its own message filtering, so honouring them here means deciding how they compose with ignore-paths and with the profile's disable list — a bigger question than this issue asks. Say the word if you'd like them in and I'll add them.

test_vulture_reads_pyproject_config runs the tool against a fixture project carrying that config; it fails on current master with read_items should have been ignored and passes with the change. ruff format and ruff check are clean under the repo's own configuration. The wider suite has four collection errors from optional tools that aren't installed here — the same four, on the clean tree and with this branch.

The thread also mentions pydocstyle having the same shape of problem; that's a separate tool wrapper and I've left it alone.

AI-assisted (LLM used for drafting); the runs above are mine.

Vulture reads that section itself, so a project that sets ignore_decorators
or ignore_names got one answer from `vulture` and a different one from
`prospector`: the tool was constructed with neither, and the settings were
never read at all.

Read them with vulture's own loader, so the two agree on what the section
means, and pass them through. min_confidence and exclude are left alone --
prospector does its own file finding and message filtering, and applying
them here would mean deciding how they compose with that.

Fixes prospector-dev#505
@Eljees

Eljees commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Duplicate of #836, which is already under review — my mistake, closing this one.

The fixture-based test from here is the better of the two, so I've moved it over to #836 in 8f73150. The implementation to keep is the one in #836: it honours use_external_config (so --no-external-config still suppresses the section) and surfaces an invalid [tool.vulture] as a V001 message instead of silently ignoring it. This PR dropped both.

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

Successfully merging this pull request may close these issues.

Vulture configuration in pyproject.toml ignored

1 participant