Open MartinThoma opened 4 years ago
Regarding ignoring results for functions which are decorated by some specific decorator:
The --ignore-decorators option can be used to ignore functions decorated with the given decorator. This is helpful for example in Flask projects, where you can use
--ignore-decorators "@app.route"
to ignore all functions with the@app.route
decorator.
For your use case, I think you can invoke Vulture like following:
vulture dir/ --ignore-decorators "@after_this_request,@app.errorhandler,@app.route"
To deal with strict_slashes
variable, I think the following whitelist should suffice:
from vulture.whitelists.whitelist_utils import Whitelist
flask_whitelist = Whitelist()
flask_whitelist.url_map.strict_slashes
It would actually be useful to put the strict_slashes
field into a whitelist that we then bundle with Vulture. Care to draft a pull request for this (see https://github.com/jendrikseipp/vulture/pull/258/files for an example)?
I've noticed some false-positives with Flask applications:
app.url_map.strict_slashes = False
(source)@app.errorhandler(SomeException)
@app.route
@after_this_request