jendrikseipp / vulture

Find dead Python code
MIT License
3.48k stars 152 forks source link

Different results when ran on a folder or on a particular file #253

Closed valyagolev closed 3 years ago

valyagolev commented 3 years ago

vulture seems like a very useful tool, yet I can't configure it quite right. Perhaps it's a bug - or a configuration issue that could be explained slightly better.

The problem persists even with the empty pyproject.toml, so I won't attach it.

% vulture . | grep 'hr/views/tables'
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:45: unused variable 'applied' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:48: unused variable 'skillsets_agg' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:49: unused variable 'work_fields_agg' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:52: unused variable 'job_types_agg' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:63: unused variable 'actions' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:89: unused variable 'applied' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:95: unused variable 'updated' (60% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:113: unused variable 'actions' (60% confidence)

% vulture zugvogl/hr/views/tables.py
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:7: unused import 'AmbassadorFeedbackColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:7: unused import 'HRCommentColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:16: unused import 'CVCheckLinkColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:16: unused import 'CVLinkColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:16: unused import 'CVStatusColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:16: unused import 'FavoriteBooleanColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:16: unused import 'HipoBooleanColumn' (90% confidence)
/Users/Valentin/Work/zugvogl/zugvogl/hr/views/tables.py:16: unused import 'StarRatingColumn' (90% confidence)
# ...many more lines...

Since unused imports are exactly what I'm after, this is something I'd love to get reported right.

RJ722 commented 3 years ago

HI @valyagolev, Vulture doesn't have the concept of namespaces -- everything Vulture collects, it stores in a common set -- which is why if a class is being used at least once in the entire codebase, it won't be reported as unused.

valyagolev commented 3 years ago

I see, thank you. Is this as intended or is this something there's a plan to change?

RJ722 commented 3 years ago

This is intended, as there's no easy way to shelter namespaces.

jendrikseipp commented 3 years ago

Thanks @RJ722 for answering this one!