From 65e4992bcdce7a114d6c00de5e26bb0a9789ecc2 Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 21 Dec 2024 21:14:48 +0200 Subject: [PATCH] best --- app/main.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..fa5cc42b 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,36 @@ 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": "failed" if len(errors) > 0 else "passed" + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [{ + "path" : path, + "status" : "failed" if len(error_list) > 0 else "passed", + "errors": [{ + "line" : error["line_number"], + "column" : error["column_number"], + "message" : error["text"], + "name" : error["code"], + "source": "flake8" + } for error in error_list] + }for path, error_list in linter_report]