From 12a0f406196fbe2055b48db58b694be094988472 Mon Sep 17 00:00:00 2001 From: Bohdan Date: Wed, 18 Dec 2024 16:38:00 +0200 Subject: [PATCH 1/2] Performance of 3 functions --- app/main.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..13315ffe 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,30 @@ 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": [format_linter_error(error) for error in errors], + "path": file_path, + "status": "failed" + + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [ + { + "errors": [format_linter_error(error) for error in errors], + "path": file_path, + "status": "failed" if errors else "passed", + } + for file_path, errors in linter_report.items() + ] + + From 0c1f11196f1d63e819a0f98c7d02c5ef9948586d Mon Sep 17 00:00:00 2001 From: Bohdan Date: Thu, 19 Dec 2024 15:13:05 +0200 Subject: [PATCH 2/2] corrected flak8 --- app/main.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index 20463c45..26905d4d 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": [format_linter_error(error) for error in errors], + "path": file_path, + "status": "failed", + } def format_linter_report(linter_report: dict) -> list: - # write your code here - pass + return [ + { + "errors": [format_linter_error(error) for error in errors], + "path": file_path, + "status": "failed" if errors else "passed", + } + for file_path, errors in linter_report.items() + ]