From a00b17132e5fd336ece2b6af4962816de8da53c9 Mon Sep 17 00:00:00 2001 From: ComfortCityBud Date: Thu, 7 Nov 2024 18:20:37 +0200 Subject: [PATCH] Solution --- app/main.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/app/main.py b/app/main.py index 6fbb0710..2611e874 100644 --- a/app/main.py +++ b/app/main.py @@ -9,32 +9,13 @@ def format_linter_error(error: dict) -> dict: def format_single_linter_file(file_path: str, errors: list) -> dict: return { - "errors": [{ - "line": key["line_number"], - "column": key["column_number"], - "message": key["text"], - "name": key["code"], - "source": "flake8" - } for key in errors], + "errors": [format_linter_error(key) + for key in errors], "path": file_path, - "status": "failed" + "status": "failed" if errors else "passed", } def format_linter_report(linter_report: dict) -> list: - return [ - {"errors": - [ - { - "line": key["line_number"], - "column": key["column_number"], - "message": key["text"], - "name": key["code"], - "source": "flake8" - } for key in linter_report[file]], - "path": file, - "status": "passed" if not linter_report[file] else "failed"} - for file in ["./test_source_code_2.py", - "./source_code_2.py", - "./source_code_1.py", - "./test_source_code_1.py"]] + return [format_single_linter_file(file_path, errors) + for file_path, errors in linter_report.items()]