From 01996c983339d85ea146aea7ec8bce9d8ac3fc21 Mon Sep 17 00:00:00 2001 From: Artyom Semidolin <43622365+Artanias@users.noreply.github.com> Date: Sun, 29 Sep 2024 14:16:43 +0300 Subject: [PATCH] refactor: corrects check when trying to create a report; CLI help messages; typing. Refs: #204. --- Makefile | 2 +- pyproject.toml | 1 - src/codeplag/codeplagcli.py | 4 ++-- src/codeplag/handlers/report.py | 2 +- test/unit/webparsers/test_github_parser.py | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c8d2ff2..6d45987 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -UTIL_VERSION := 0.5.5 +UTIL_VERSION := 0.5.6 UTIL_NAME := codeplag PWD := $(shell pwd) diff --git a/pyproject.toml b/pyproject.toml index 79311bd..086fa35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ lint.ignore = [ "ANN102", "ANN201", "ANN204", - "ANN206", "ANN401", # dynamically typed expressions (typing.Any) "D100", "D101", diff --git a/src/codeplag/codeplagcli.py b/src/codeplag/codeplagcli.py index cf6cdd8..b1831fc 100644 --- a/src/codeplag/codeplagcli.py +++ b/src/codeplag/codeplagcli.py @@ -287,7 +287,7 @@ def __add_report_path(self: Self, subparsers: argparse._SubParsersAction) -> Non ) report_commands = report.add_subparsers( - help=_("Report commands of the '{util_name}' util.").format(util_name={UTIL_NAME}), + help=_("Report commands of the '{util_name}' util.").format(util_name=UTIL_NAME), required=True, metavar="COMMAND", dest="report", @@ -302,7 +302,7 @@ def __add_report_path(self: Self, subparsers: argparse._SubParsersAction) -> Non "-p", "--path", help=_( - "Path to save generated report. " "If it's a directory, then create a file in it." + "Path to save generated report. If it's a directory, then create a file in it." ), required=True, type=Path, diff --git a/src/codeplag/handlers/report.py b/src/codeplag/handlers/report.py index 173874c..ac90639 100644 --- a/src/codeplag/handlers/report.py +++ b/src/codeplag/handlers/report.py @@ -58,7 +58,7 @@ def html_report_create(report_path: Path, report_type: ReportType) -> Literal[0, if settings_config["reports_extension"] != "csv": logger.error("Can create report only when 'reports_extension' is csv.") return 1 - if not reports_path.exists(): + if not (reports_path / CSV_REPORT_FILENAME).exists(): logger.error(f"There is nothing in '{reports_path}' to create a basic html report from.") return 1 create_report_function = _create_report if report_type == "general" else _create_sources_report diff --git a/test/unit/webparsers/test_github_parser.py b/test/unit/webparsers/test_github_parser.py index 7305dd2..4d7bee8 100644 --- a/test/unit/webparsers/test_github_parser.py +++ b/test/unit/webparsers/test_github_parser.py @@ -64,7 +64,7 @@ def raise_for_status(self: Self) -> None: class TestGitHubParser(unittest.TestCase): @classmethod - def setUpClass(cls): + def setUpClass(cls: type["TestGitHubParser"]) -> None: cls.maxDiff = None def test__is_accepted_extension(self: Self) -> None: