From 0f96fcb5a9dafab1e55ed22e5356257712b6035f Mon Sep 17 00:00:00 2001 From: Vasyl Date: Fri, 20 Dec 2024 23:38:48 +0200 Subject: [PATCH] writed 3 functions to convert the report into the new format --- app/main.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..4d67aa5c 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,25 @@ 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": [ + format_linter_error(error) for error in errors + ], + "path": file_path, + "status": "failed" if errors else "passed" + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [ + format_single_linter_file(key, value) + for key, value in linter_report.items() + ]