From 4efa9764f8de9b6c59488b18ca67a942563d4b5d Mon Sep 17 00:00:00 2001 From: Sviatoslav Antonishyn Date: Tue, 17 Dec 2024 13:35:59 +0200 Subject: [PATCH] 'Solution' --- app/main.py | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..9783d2bd 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,40 @@ def format_linter_error(error: dict) -> dict: - # write your code here - pass + return { + "line": error["line_number"], "column": error["column_number"], + "message": error["text"], "name": error["code"], "source": "flake8" + } def format_single_linter_file(file_path: str, errors: list) -> dict: - # write your code here - pass + return { + "errors": [ + { + "line": error["line_number"], + "column": error["column_number"], + "message": error["text"], + "name": error["code"], "source": "flake8" + } + for error in errors + ], + "path": file_path, "status": ("passed" if errors == [] else "failed") + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [ + { + "errors": [ + { + "line": error["line_number"], + "column": error["column_number"], + "message": error["text"], + "name": error["code"], + "source": "flake8" + } + for error in errors + ], + "path": file, + "status": ("passed" if errors == [] else "failed") + } + for file, errors in linter_report.items() + ]