From a13cc1f6ab08daa0996bb8b82cd6407b9a7bb839 Mon Sep 17 00:00:00 2001 From: Illia Khomutov Date: Sat, 15 Jul 2023 19:28:47 +0300 Subject: [PATCH 1/2] Solution --- app/main.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..adc8eb25 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": [{"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 errors else "passed")} def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [ + { + "errors": [{"line": line["line_number"], + "column": line["column_number"], + "message": line["text"], "name": line["code"], + "source": "flake8"} for line in value], + "path": key, + "status": ("failed" if value else "passed") + } + for key, value in linter_report.items()] From ffca6e6c65b4445e5933ba97203527960dbcc6e5 Mon Sep 17 00:00:00 2001 From: Illia Khomutov Date: Sun, 16 Jul 2023 21:50:51 +0300 Subject: [PATCH 2/2] Solution --- app/main.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/main.py b/app/main.py index adc8eb25..99ac6fb6 100644 --- a/app/main.py +++ b/app/main.py @@ -1,26 +1,23 @@ def format_linter_error(error: dict) -> dict: return { - "line": error["line_number"], "column": error["column_number"], - "message": error["text"], "name": error["code"], + "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": [{"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 errors else "passed")} + 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: return [ { - "errors": [{"line": line["line_number"], - "column": line["column_number"], - "message": line["text"], "name": line["code"], - "source": "flake8"} for line in value], + "errors": [format_linter_error(line) for line in value], "path": key, "status": ("failed" if value else "passed") }