From 07a313ba4b649d47b20c3c9cb621a5ca5a69c8c8 Mon Sep 17 00:00:00 2001 From: CryptoQwest Date: Thu, 10 Oct 2024 14:49:36 +0200 Subject: [PATCH 1/3] 'Solution' --- app/main.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..0871f43b 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 +from calendar import error +from idlelib.iomenu import errors -def format_single_linter_file(file_path: str, errors: list) -> dict: - # write your code here - pass +def format_linter_error(error: dict) -> dict: + 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: + 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(file_path, errors) + for file_path, errors in linter_report.items() + ] From 5b64201b960e3c90c292f6bee838f8a0b083e653 Mon Sep 17 00:00:00 2001 From: CryptoQwest Date: Thu, 10 Oct 2024 14:56:35 +0200 Subject: [PATCH 2/3] 'Solution' --- app/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/main.py b/app/main.py index 0871f43b..8967f220 100644 --- a/app/main.py +++ b/app/main.py @@ -3,6 +3,8 @@ def format_linter_error(error: dict) -> dict: + + return { "line": error["line_number"], "column": error["column_number"], @@ -12,6 +14,8 @@ def format_linter_error(error: dict) -> dict: } def format_single_linter_file(file_path: str, errors: list) -> dict: + + return { errors: [format_linter_error(error) for error in errors], "path": file_path, @@ -19,6 +23,8 @@ def format_single_linter_file(file_path: str, errors: list) -> dict: } def format_linter_report(linter_report: dict) -> list: + + return [ format_single_linter_file(file_path, errors) for file_path, errors in linter_report.items() From ef971ba3bbbb7d862ca9509ee4668f79e79cc249 Mon Sep 17 00:00:00 2001 From: CryptoQwest Date: Thu, 10 Oct 2024 15:01:41 +0200 Subject: [PATCH 3/3] 'Solution-fixed' --- app/main.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/main.py b/app/main.py index 8967f220..09392291 100644 --- a/app/main.py +++ b/app/main.py @@ -1,10 +1,7 @@ from calendar import error -from idlelib.iomenu import errors def format_linter_error(error: dict) -> dict: - - return { "line": error["line_number"], "column": error["column_number"], @@ -14,17 +11,13 @@ def format_linter_error(error: dict) -> dict: } def format_single_linter_file(file_path: str, errors: list) -> dict: - - return { - errors: [format_linter_error(error) for error in errors], + "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: - - return [ format_single_linter_file(file_path, errors) for file_path, errors in linter_report.items()