Imagine we have some giant legacy code base with a lot of files with ignored Mypy warnings:
def foobar():
x = some_external_class.some_method()[0] # type: ignore[ignore-some-mypy-warning]
Time to go...
Some parts of code were changed. Some parts of code is still the same. How to check every "ignore" comment to know: will I get an error if I remove it?
Desired output:
Checked 100500 files!
You do not need "ignore" comments anymore in the following files:
- spam.py:534
- eggs.py:31
- eggs.py:250
Is there any existing tools to achieve this? Any ideas about custom scripts?
UPD:
The only idea that I have:
- Write a script that will find and remember a file and a line of every Mypy comment.
- Find and remove ALL Mypy comments.
- Run Mypy check -> store results.
- Compare the Mypy check errors lines with a stored OLD lines.
- Find a difference: if a comment was removed, but Mypy does not complain now about that line, then the comment must be removed.