fix(mypy): Fix files in scripts/ (#4320)

This commit is contained in:
Christian Clauss 2021-04-07 04:42:56 +02:00 committed by GitHub
parent 531d2d6d7e
commit 252df0a149
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -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*)/$

View File

@ -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!"

View File

@ -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}"