jendrikseipp / vulture

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

False positive on unused attribute #257

Closed bje- closed 3 years ago

bje- commented 3 years ago

Packages like pint use attributes to control behaviour. Here is a very simple example:

import pint
ureg = pint.UnitRegistry()
ureg.default_format = '.2f~P'

Vulture reports that the attribute is unused:

foo.py:3: unused attribute 'default_format' (60% confidence)
jendrikseipp commented 3 years ago

That sounds like a good fit for a pint whitelist:

import pint
ureg = pint.UnitRegistry()
ureg.default_format

If you pass this file to Vulture in addition to your normal files, Vulture will not complain.

If you like, you could prepare a pull request for this by putting the code into a file called vuture/whitelists/pint.py

bje- commented 3 years ago

Thanks, will do.