From bd2b27eccf6ceac81901aa05a2366a1e8783ced4 Mon Sep 17 00:00:00 2001 From: Nadiia Date: Fri, 21 Jul 2023 16:15:31 +0300 Subject: [PATCH] Solution py-linter-formatter --- app/main.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..a82d0a0f 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,23 @@ def format_linter_error(error: dict) -> dict: - # write your code here - pass + return { + "line": error.get("line_number"), + "column": error.get("column_number"), + "message": error.get("text"), + "name": error.get("code"), + "source": "flake8" + + } def format_single_linter_file(file_path: str, errors: list) -> dict: - # write your code here - pass + return { + "path": file_path, + "status": "failed" if errors else "passed", + "errors": + [format_linter_error(error) for error in errors] + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [format_single_linter_file(file_path, errors) + for file_path, errors in linter_report.items()]