From 0632226c1581a69c2a7d396aeba8c31a90a96270 Mon Sep 17 00:00:00 2001 From: Iryna Mishchenko Date: Sat, 19 Oct 2024 19:54:07 +0200 Subject: [PATCH] Solution --- .flake8 | 2 +- app/main.py | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.flake8 b/.flake8 index d7459204..99d2e123 100644 --- a/.flake8 +++ b/.flake8 @@ -4,4 +4,4 @@ ignore = E203, E266, W503, ANN002, ANN003, ANN101, ANN102, ANN401, N807, N818 max-line-length = 79 max-complexity = 18 select = B,C,E,F,W,T4,B9,ANN,Q0,N8,VNE -exclude = venv, tests +exclude = .venv, tests diff --git a/app/main.py b/app/main.py index 20463c45..ce813a8c 100644 --- a/app/main.py +++ b/app/main.py @@ -1,13 +1,23 @@ 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": "passed" if not errors else "failed" + } 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() + ]