Closed dsuch closed 2 years ago
Nice tip! Do you want to make a pull request that adds this to the README under "Handling false positives"?
That seems like an antipattern to me, given that there is a generally accepted way of fixing the same problem, namely using if typing.TYPE_CHECKING:
(docs)
Hello,
this is just a quick hint that I am leaving for people who would like to use vulture with code that uses imports guarded by "if 0:", "if False:" or similar checks and who would not like to resort to the "debug = False / if debug:" or similar approaches because they use "if 0:" with a specific goal in mind, which is solely to let type checkers know what types there exist, which means that such imports are never "dead" code.
The hint is to use this:
It is almost as concise as "if 0:" and vulture does not reject it with a message that it is an "unsatisfiable 'if' condition (100% confidence)."
Same goes for mypy and pyright, both accept it.