From e5be31d9f9c26d4a6e5742b26b5b9361d9fdc030 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Sep 2024 16:29:09 +0300 Subject: [PATCH] created 3 function as "comprehension" --- app/main.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..0ea67444 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,27 @@ 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 [ + { + "errors": [format_linter_error(error) for error in errors], + "path": path, + "status": ("failed" if errors else "passed") + } + for path, errors in linter_report.items() + ]