vulture icon indicating copy to clipboard operation
vulture copied to clipboard

How to ignore all test_*.py files?

Open srossross opened this issue 3 years ago • 2 comments

The exclude argument does not appear to work the way I was expecting

vulture plantiga_analytics/ --exclude 'test_*.py'

plantiga_analytics/test_compute_main.py:290: unused attribute 'return_value' (60% confidence)
plantiga_analytics/test_compute_main.py:292: unused attribute 'side_effect' (60% confidence)
plantiga_analytics/test_compute_main.py:294: unused attribute 'return_value' (60% confidence)

srossross avatar Jun 02 '21 21:06 srossross

Maybe you need '*test_*.py

noorul avatar Jul 17 '21 14:07 noorul

@noorul is correct. You can also use something like **/*/test_*.py.

RJ722 avatar Jul 17 '21 20:07 RJ722

Thanks, this was helpful :-) but I personally don't quite understand why in my situation I need vulture '--exclude=*env/**' . for my venv situated at ./env - I tried --exclude=env/**, ./env/**, /env/**, nothing seems to work :-)

Cheaterman avatar Dec 14 '22 16:12 Cheaterman

Thanks for the report! The --exclude patterns are matched against absolute paths. I clarified this in the help output and the README now.

jendrikseipp avatar Jan 08 '23 17:01 jendrikseipp

Thanks for the report! The --exclude patterns are matched against absolute paths. I clarified this in the help output and the README now.

I'm curious about the rationale for this design decision. It seems rather counterintuitive and error-prone to me; it may lead to things like people with different usernames (and thus different home directories) getting different warnings unless the globs are carefully crafted.

sliedes avatar Sep 18 '23 08:09 sliedes

@sliedes Can you provide a concrete problematic example for this, please? Which behaviour would you expect for --exclude?

jendrikseipp avatar Sep 22 '23 17:09 jendrikseipp

It just feels very surprising to me; normally, in my experience projects are developed so that you have some "project directory", perhaps a checked out repository, and you'd in my view want the checks to run deterministically inside it regardless of its location in the filesystem.

I have not encountered any pathological examples in practice (well, I only started looking into vulture last week), but I could imagine patterns written with less care like (borrowing from the discussion above) --exclude **/env/*, where everything gets excluded for the poor new intern whose username happens to be "env" and home directory /home/env.

It just seems like a needless pitfall to me. :)

sliedes avatar Sep 25 '23 09:09 sliedes

Thanks for the explanation! I hope that #310 will improve the situation.

jendrikseipp avatar Oct 10 '23 17:10 jendrikseipp