From 99f81f06383207c6d88e58de616dccaa5c0a6659 Mon Sep 17 00:00:00 2001 From: Mykyta Date: Tue, 19 Sep 2023 23:52:46 +0300 Subject: [PATCH 1/8] Solution --- app/main.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..04599bcd 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,11 @@ 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": 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"} for file_path, errors in linter_report.items()] From e716b4cb41e979c1c3b0fc1d8101a7323af291ad Mon Sep 17 00:00:00 2001 From: Mykyta Date: Tue, 19 Sep 2023 23:57:34 +0300 Subject: [PATCH 2/8] Solution1 --- app/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 04599bcd..70585b05 100644 --- a/app/main.py +++ b/app/main.py @@ -4,8 +4,18 @@ def format_linter_error(error: dict) -> dict: 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": [{"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: - 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"} for file_path, errors in linter_report.items()] + 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" + } for file_path, errors in linter_report.items() + ] From 17c4f504c29471fb163ee6ab13e12ca92f7fdf8a Mon Sep 17 00:00:00 2001 From: Mykyta Date: Tue, 19 Sep 2023 23:59:25 +0300 Subject: [PATCH 3/8] Solution2 --- app/main.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/app/main.py b/app/main.py index 70585b05..a1a9df54 100644 --- a/app/main.py +++ b/app/main.py @@ -1,21 +1,42 @@ def format_linter_error(error: dict) -> dict: - return {"line": error["line_number"], "column": error["column_number"], "message": error["text"], - "name": error["code"], "source": "flake8"} + 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": [{"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" + "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: 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" + "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" } for file_path, errors in linter_report.items() ] From 2a6a26993d8652302d87791ed84afdd06b369632 Mon Sep 17 00:00:00 2001 From: Mykyta Date: Wed, 20 Sep 2023 13:06:23 +0300 Subject: [PATCH 4/8] Solution3 --- app/main.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/app/main.py b/app/main.py index a1a9df54..1144e092 100644 --- a/app/main.py +++ b/app/main.py @@ -25,18 +25,4 @@ def format_single_linter_file(file_path: str, errors: list) -> dict: def format_linter_report(linter_report: dict) -> list: - 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" - } for file_path, errors in linter_report.items() - ] + return [format_single_linter_file(file_path, errors) for file_path, errors in linter_report.items()] From 09c387130933fe4c947d73c9087bc4a2c7bf7013 Mon Sep 17 00:00:00 2001 From: Mykyta Date: Wed, 20 Sep 2023 13:09:53 +0300 Subject: [PATCH 5/8] Solution4 --- app/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 1144e092..ed86e669 100644 --- a/app/main.py +++ b/app/main.py @@ -25,4 +25,5 @@ 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()] + return [format_single_linter_file(file_path, errors) + for file_path, errors in linter_report.items()] From 30dfa5cc4ca8458ae426aa9a96f9cf7674a42bd1 Mon Sep 17 00:00:00 2001 From: Mykyta Date: Wed, 20 Sep 2023 20:46:19 +0300 Subject: [PATCH 6/8] Solution5 --- app/main.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/main.py b/app/main.py index ed86e669..ca6998fd 100644 --- a/app/main.py +++ b/app/main.py @@ -10,15 +10,7 @@ def format_linter_error(error: dict) -> dict: 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 - ], + "errors": [format_linter_error(error) for error in errors], "path": file_path, "status": "failed" if errors else "passed" } From 1c823b55ceed839aa7df6a7f9faebeffae309005 Mon Sep 17 00:00:00 2001 From: Mykyta Date: Wed, 20 Sep 2023 21:32:45 +0300 Subject: [PATCH 7/8] Solution6 --- app/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index ca6998fd..c1207c2a 100644 --- a/app/main.py +++ b/app/main.py @@ -17,5 +17,7 @@ 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()] + return [ + format_single_linter_file(file_path, errors) + for file_path, errors in linter_report.items() + ] From 97d0716a6de081ee73a5e815d3b13c3f34605b32 Mon Sep 17 00:00:00 2001 From: Mykyta Date: Wed, 20 Sep 2023 21:34:46 +0300 Subject: [PATCH 8/8] Solution7 --- app/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index c1207c2a..5a1c6a6d 100644 --- a/app/main.py +++ b/app/main.py @@ -19,5 +19,5 @@ 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() + for file_path, errors in linter_report.items() ]