mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
fix(mypy): Fix files in scripts/ (#4320)
This commit is contained in:
parent
531d2d6d7e
commit
252df0a149
2
mypy.ini
2
mypy.ini
|
@ -2,4 +2,4 @@
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
||||||
; FIXME: #4052 fix mypy errors in the exclude directories and remove them below
|
; FIXME: #4052 fix mypy errors in the exclude directories and remove them below
|
||||||
exclude = (data_structures|dynamic_programming|graphs|maths|matrix|other|project_euler|scripts|searches|strings*)/$
|
exclude = (data_structures|dynamic_programming|graphs|maths|matrix|other|project_euler|searches|strings*)/$
|
||||||
|
|
|
@ -4,7 +4,7 @@ import os
|
||||||
try:
|
try:
|
||||||
from .build_directory_md import good_file_paths
|
from .build_directory_md import good_file_paths
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from build_directory_md import good_file_paths
|
from build_directory_md import good_file_paths # type: ignore
|
||||||
|
|
||||||
filepaths = list(good_file_paths())
|
filepaths = list(good_file_paths())
|
||||||
assert filepaths, "good_file_paths() failed!"
|
assert filepaths, "good_file_paths() failed!"
|
||||||
|
|
|
@ -22,7 +22,7 @@ def convert_path_to_module(file_path: pathlib.Path) -> ModuleType:
|
||||||
"""Converts a file path to a Python module"""
|
"""Converts a file path to a Python module"""
|
||||||
spec = importlib.util.spec_from_file_location(file_path.name, str(file_path))
|
spec = importlib.util.spec_from_file_location(file_path.name, str(file_path))
|
||||||
module = importlib.util.module_from_spec(spec)
|
module = importlib.util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module) # type: ignore
|
||||||
return module
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,5 +89,5 @@ def test_project_euler(solution_path: pathlib.Path) -> None:
|
||||||
problem_number: str = solution_path.parent.name[8:].zfill(3)
|
problem_number: str = solution_path.parent.name[8:].zfill(3)
|
||||||
expected: str = PROBLEM_ANSWERS[problem_number]
|
expected: str = PROBLEM_ANSWERS[problem_number]
|
||||||
solution_module = convert_path_to_module(solution_path)
|
solution_module = convert_path_to_module(solution_path)
|
||||||
answer = str(solution_module.solution())
|
answer = str(solution_module.solution()) # type: ignore
|
||||||
assert answer == expected, f"Expected {expected} but got {answer}"
|
assert answer == expected, f"Expected {expected} but got {answer}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user