Enable ruff PGH003 rule (#11345)

* Enable ruff PGH003 rule

* Fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Maxim Smolskiy
2024-04-02 22:29:34 +03:00
committed by GitHub
parent f5bbea3776
commit 53b2926704
14 changed files with 20 additions and 19 deletions

View File

@ -21,8 +21,8 @@ with open(PROJECT_EULER_ANSWERS_PATH) as file_handle:
def convert_path_to_module(file_path: pathlib.Path) -> ModuleType:
"""Converts a file path to a Python module"""
spec = importlib.util.spec_from_file_location(file_path.name, str(file_path))
module = importlib.util.module_from_spec(spec) # type: ignore
spec.loader.exec_module(module) # type: ignore
module = importlib.util.module_from_spec(spec) # type: ignore[arg-type]
spec.loader.exec_module(module) # type: ignore[union-attr]
return module
@ -92,7 +92,7 @@ def test_project_euler(solution_path: pathlib.Path) -> None:
problem_number: str = solution_path.parent.name[8:].zfill(3)
expected: str = PROBLEM_ANSWERS[problem_number]
solution_module = convert_path_to_module(solution_path)
answer = str(solution_module.solution()) # type: ignore
answer = str(solution_module.solution())
answer = hashlib.sha256(answer.encode()).hexdigest()
assert (
answer == expected