From 7d0631b94985f76305e065b947315ee4ba5fe755 Mon Sep 17 00:00:00 2001 From: Bartolomeu Date: Thu, 24 Oct 2024 02:43:33 +0200 Subject: [PATCH 1/2] Solution --- app/main.py | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..ecbfd672 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,41 @@ 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 { + "path": file_path, + "status": "passed" + } + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + + return [ + { + "errors": + [ + format_linter_error(value2) + for value2 in value + ], + "path": key, + "status": "failed" if len(value) > 0 else "passed" + } for key, value in linter_report.items() + ] From 9f7ab0be893eb7177aeeab7e9ad4aaa21dda7d74 Mon Sep 17 00:00:00 2001 From: Bartolomeu Date: Thu, 24 Oct 2024 02:53:56 +0200 Subject: [PATCH 2/2] Solution --- app/main.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index ecbfd672..e3218407 100644 --- a/app/main.py +++ b/app/main.py @@ -17,12 +17,7 @@ def format_single_linter_file(file_path: str, errors: list) -> dict: for error in errors ], "path": file_path, - "status": "failed" - if len(errors) > 0 - else { - "path": file_path, - "status": "passed" - } + "status": "failed" if len(errors) > 0 else "passed" }