Closed algobytewise closed 3 years ago
The mypy documentation of this issue can be found here: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
@cclauss just pointed out to me that the automatic checks already include the ignore-missing-imports parameter, so the implementation errors don't need to be fixed. See https://github.com/TheAlgorithms/Python/blob/master/.pre-commit-config.yaml#L33
Those tests are commented out so it would be awesome if we could put the fixes in place so that we can automatically run mypy -ignore-missing-imports .
on every pull request.
% mypy --ignore-missing-imports . > files.txt
% python3
>>> with open("files.txt") as in_file:
... print("\n* [ ] ".join(sorted(set(line.split(":")[0] for line in in_file))))
...
So... We can successfully run
% mypy --ignore-missing-imports arithmetic_analysis backtracking bit_manipulation blockchain boolean_algebra cellular_automata computer_vision digital_image_processing fuzzy_logic genetic_algorithm geodesy knapsack networking_flow scheduling sorts
Success: no issues found in 138 source files
Let's focus the mypy discussions on #4052
Many of the current errors when running the command
mypy .
are implementation errors of the following form:scheduling\shortest_job_first.py:8: error: Cannot find implementation or library stub for module named 'pandas'
. These errors can be fixed by adding the comment# type: ignore
at the end of the line, thereby telling mypy to ignore them, for exampleimport pandas as pd # type: ignore
. But all these errors can be silenced by running the commandmypy . --ignore-missing-imports
, avoiding the need to fix them one by one. So the question is: should these errors be fixed for each file or can they be ignored since the check to be implemented will silence them anyways? Without the ignore-parameter, we have:Found 586 errors in 189 files
. With it, we have:Found 477 errors in 132 files
.