From 71643eecd8a04ec3e9fd490475719a0dbb3bd614 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Sun, 18 May 2025 03:11:35 -0400 Subject: [PATCH 1/6] Giving help love --- diff_cover/diff_cover_tool.py | 51 ++++++++++++++++++----------------- verify.sh | 8 +++--- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/diff_cover/diff_cover_tool.py b/diff_cover/diff_cover_tool.py index 782415a8..128194e9 100644 --- a/diff_cover/diff_cover_tool.py +++ b/diff_cover/diff_cover_tool.py @@ -24,20 +24,18 @@ HTML_REPORT_HELP = "Diff coverage HTML output" JSON_REPORT_HELP = "Diff coverage JSON output" MARKDOWN_REPORT_HELP = "Diff coverage Markdown output" -COMPARE_BRANCH_HELP = "Branch to compare" +COMPARE_BRANCH_HELP = "Branch to compare (default: %(default)s)" CSS_FILE_HELP = "Write CSS into an external file" -FAIL_UNDER_HELP = ( - "Returns an error code if coverage or quality score is below this value" -) +FAIL_UNDER_HELP = "Returns an error code if coverage or quality score is below this value (default: %(default)s)" IGNORE_STAGED_HELP = "Ignores staged changes" IGNORE_UNSTAGED_HELP = "Ignores unstaged changes" IGNORE_WHITESPACE = "When getting a diff ignore any and all whitespace" EXCLUDE_HELP = "Exclude files, more patterns supported" INCLUDE_HELP = "Files to include (glob pattern)" -SRC_ROOTS_HELP = "List of source directories (only for jacoco coverage reports)" +SRC_ROOTS_HELP = "List of source directories (only for jacoco coverage reports) (default: %(default)s)" COVERAGE_FILE_HELP = "coverage report (XML or lcov.info)" DIFF_RANGE_NOTATION_HELP = ( - "Git diff range notation to use when comparing branches, defaults to '...'" + "Git diff range notation to use when comparing branches (default: '%(default)s')" ) QUIET_HELP = "Only print errors and failures" SHOW_UNCOVERED = "Show uncovered lines on the console" @@ -93,13 +91,13 @@ def parse_coverage_args(argv): ) parser.add_argument( - "--show-uncovered", action="store_true", default=None, help=SHOW_UNCOVERED + "--show-uncovered", action="store_true", default=False, help=SHOW_UNCOVERED ) parser.add_argument( "--expand-coverage-report", action="store_true", - default=None, + default=False, help=EXPAND_COVERAGE_REPORT, ) @@ -113,29 +111,30 @@ def parse_coverage_args(argv): parser.add_argument( "--compare-branch", metavar="BRANCH", + default="origin/main", type=str, help=COMPARE_BRANCH_HELP, ) parser.add_argument( - "--fail-under", metavar="SCORE", type=float, default=None, help=FAIL_UNDER_HELP + "--fail-under", metavar="SCORE", type=float, default=0, help=FAIL_UNDER_HELP ) parser.add_argument( - "--ignore-staged", action="store_true", default=None, help=IGNORE_STAGED_HELP + "--ignore-staged", action="store_true", default=False, help=IGNORE_STAGED_HELP ) parser.add_argument( "--ignore-unstaged", action="store_true", - default=None, + default=False, help=IGNORE_UNSTAGED_HELP, ) parser.add_argument( "--include-untracked", action="store_true", - default=None, + default=False, help=INCLUDE_UNTRACKED_HELP, ) @@ -152,6 +151,7 @@ def parse_coverage_args(argv): metavar="DIRECTORY", type=str, nargs="+", + default=["src/main/java", "src/test/java"], help=SRC_ROOTS_HELP, ) @@ -160,6 +160,7 @@ def parse_coverage_args(argv): metavar="RANGE_NOTATION", type=str, choices=["...", ".."], + default="...", help=DIFF_RANGE_NOTATION_HELP, ) @@ -168,12 +169,12 @@ def parse_coverage_args(argv): parser.add_argument( "--ignore-whitespace", action="store_true", - default=None, + default=False, help=IGNORE_WHITESPACE, ) parser.add_argument( - "-q", "--quiet", action="store_true", default=None, help=QUIET_HELP + "-q", "--quiet", action="store_true", default=False, help=QUIET_HELP ) parser.add_argument( @@ -183,17 +184,17 @@ def parse_coverage_args(argv): parser.add_argument("--diff-file", type=str, default=None, help=DIFF_FILE_HELP) defaults = { - "show_uncovered": False, - "compare_branch": "origin/main", - "fail_under": 0, - "ignore_staged": False, - "ignore_unstaged": False, - "ignore_untracked": False, - "src_roots": ["src/main/java", "src/test/java"], - "ignore_whitespace": False, - "diff_range_notation": "...", - "quiet": False, - "expand_coverage_report": False, + # "show_uncovered": False, + # "compare_branch": , + # "fail_under": 0, + # "ignore_staged": False, + # "ignore_unstaged": False, + # "ignore_untracked": False, + # "src_roots": ["src/main/java", "src/test/java"], + # "ignore_whitespace": False, + # "diff_range_notation": "...", + # "quiet": False, + # "expand_coverage_report": False, } return get_config(parser=parser, argv=argv, defaults=defaults, tool=Tool.DIFF_COVER) diff --git a/verify.sh b/verify.sh index 99996d59..bd0bfdde 100755 --- a/verify.sh +++ b/verify.sh @@ -1,6 +1,7 @@ #!/bin/bash set -euo pipefail IFS=$'\n\t' +COMPARE_BRANCH=${COMPARE_BRANCH:-origin/main} black diff_cover tests --check isort diff_cover tests --check @@ -8,8 +9,7 @@ python -m pytest -n auto --cov-context test --cov --cov-report=xml tests git fetch origin main:refs/remotes/origin/main diff-cover --version diff-quality --version -diff-cover coverage.xml --include-untracked -diff-quality --violations flake8 --include-untracked -diff-quality --violations pylint --include-untracked +diff-cover coverage.xml --include-untracked --compare-branch=$COMPARE_BRANCH +diff-quality --violations flake8 --include-untracked --compare-branch=$COMPARE_BRANCH +diff-quality --violations pylint --include-untracked --compare-branch=$COMPARE_BRANCH doc8 README.rst --ignore D001 - From 186d26198dc2ccd879e9367d02fd89b695b4ad66 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Sun, 18 May 2025 03:33:18 -0400 Subject: [PATCH 2/6] wip --- diff_cover/config_parser.py | 11 +++------- diff_cover/diff_cover_tool.py | 16 +------------- diff_cover/diff_quality_tool.py | 30 ++++++++----------------- tests/test_config_parser.py | 39 +++++++++++++++------------------ 4 files changed, 31 insertions(+), 65 deletions(-) diff --git a/diff_cover/config_parser.py b/diff_cover/config_parser.py index e9281eb4..6610c422 100644 --- a/diff_cover/config_parser.py +++ b/diff_cover/config_parser.py @@ -70,21 +70,16 @@ def _parse_config_file(file_name, tool): raise ParserError(f"No config parser could handle {file_name}") -def get_config(parser, argv, defaults, tool): +def get_config(parser, argv, tool): cli_config = vars(parser.parse_args(argv)) if cli_config["config_file"]: file_config = _parse_config_file(cli_config["config_file"], tool) else: file_config = {} - config = defaults + config = {} for config_dict in [file_config, cli_config]: for key, value in config_dict.items(): - if value is None: - # if the value is None, it's a default one; only override if not present - config.setdefault(key, value) - else: - # else just override the existing value - config[key] = value + config[key] = value return config diff --git a/diff_cover/diff_cover_tool.py b/diff_cover/diff_cover_tool.py index 128194e9..94ab26db 100644 --- a/diff_cover/diff_cover_tool.py +++ b/diff_cover/diff_cover_tool.py @@ -183,21 +183,7 @@ def parse_coverage_args(argv): parser.add_argument("--diff-file", type=str, default=None, help=DIFF_FILE_HELP) - defaults = { - # "show_uncovered": False, - # "compare_branch": , - # "fail_under": 0, - # "ignore_staged": False, - # "ignore_unstaged": False, - # "ignore_untracked": False, - # "src_roots": ["src/main/java", "src/test/java"], - # "ignore_whitespace": False, - # "diff_range_notation": "...", - # "quiet": False, - # "expand_coverage_report": False, - } - - return get_config(parser=parser, argv=argv, defaults=defaults, tool=Tool.DIFF_COVER) + return get_config(parser=parser, argv=argv, tool=Tool.DIFF_COVER) def generate_coverage_report( diff --git a/diff_cover/diff_quality_tool.py b/diff_cover/diff_quality_tool.py index 9400ca0c..29cae601 100644 --- a/diff_cover/diff_quality_tool.py +++ b/diff_cover/diff_quality_tool.py @@ -136,6 +136,7 @@ def parse_quality_args(argv): "--compare-branch", metavar="BRANCH", type=str, + default="origin/main", help=COMPARE_BRANCH_HELP, ) @@ -144,24 +145,24 @@ def parse_quality_args(argv): parser.add_argument("--options", type=str, nargs="?", help=OPTIONS_HELP) parser.add_argument( - "--fail-under", metavar="SCORE", type=float, help=FAIL_UNDER_HELP + "--fail-under", metavar="SCORE", type=float, default=0, help=FAIL_UNDER_HELP ) parser.add_argument( - "--ignore-staged", action="store_true", default=None, help=IGNORE_STAGED_HELP + "--ignore-staged", action="store_true", default=False, help=IGNORE_STAGED_HELP ) parser.add_argument( "--ignore-unstaged", action="store_true", - default=None, + default=False, help=IGNORE_UNSTAGED_HELP, ) parser.add_argument( "--include-untracked", action="store_true", - default=None, + default=False, help=INCLUDE_UNTRACKED_HELP, ) @@ -177,6 +178,7 @@ def parse_quality_args(argv): "--diff-range-notation", metavar="RANGE_NOTATION", type=str, + default="...", help=DIFF_RANGE_NOTATION_HELP, ) @@ -188,12 +190,12 @@ def parse_quality_args(argv): parser.add_argument( "--ignore-whitespace", action="store_true", - default=None, + default=False, help=IGNORE_WHITESPACE, ) parser.add_argument( - "-q", "--quiet", action="store_true", default=None, help=QUIET_HELP + "-q", "--quiet", action="store_true", default=False, help=QUIET_HELP ) parser.add_argument( @@ -204,21 +206,7 @@ def parse_quality_args(argv): "--report-root-path", help=REPORT_ROOT_PATH_HELP, metavar="ROOT_PATH" ) - defaults = { - "ignore_whitespace": False, - "compare_branch": "origin/main", - "diff_range_notation": "...", - "input_reports": [], - "fail_under": 0, - "ignore_staged": False, - "ignore_unstaged": False, - "ignore_untracked": False, - "quiet": False, - } - - return get_config( - parser=parser, argv=argv, defaults=defaults, tool=Tool.DIFF_QUALITY - ) + return get_config(parser=parser, argv=argv, tool=Tool.DIFF_QUALITY) def generate_quality_report( diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index eb0e300f..7591b6e1 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -1,4 +1,5 @@ import pytest +import argparse from diff_cover import config_parser from diff_cover.config_parser import ParserError, TOMLParser, Tool, get_config @@ -56,45 +57,41 @@ def test_get_config_unrecognized_file(mocker, tool): parser = mocker.Mock() parser.parse_args().__dict__ = {"config_file": "foo.bar"} with pytest.raises(ParserError): - get_config(parser, argv=[], defaults={}, tool=tool) + get_config(parser, argv=[], tool=tool) @pytest.mark.parametrize( - "tool,cli_config,defaults,file_content,expected", + "tool,argv,file_content,expected", [ ( Tool.DIFF_COVER, - {"a": 2, "b": None, "c": None}, - {"a": 4, "b": 3}, + ["-a", 2], None, - {"a": 2, "b": 3, "c": None}, + {"a": 2, "b": None, "c": None}, ), ( Tool.DIFF_QUALITY, - {"a": 2, "b": None, "c": None}, - {"a": 4, "b": 3}, + ["-a", 3], None, - {"a": 2, "b": 3, "c": None}, + {"a": 3, "b": None, "c": None}, ), ( Tool.DIFF_COVER, - {"a": 2, "b": None, "c": None, "d": None}, - {"a": 4, "b": 3}, - "[tool.diff_cover]\na=1\nd=6", - {"a": 2, "b": 3, "c": None, "d": 6}, + ["-a", 2, "c", 1], + "[tool.diff_cover]\na=1\nb=6", + {"a": 2, "b": 6, "c": 1}, ), ], ) -def test_get_config( - mocker, tmp_path, tool, cli_config, defaults, file_content, expected -): +def test_get_config(tmp_path, tool, argv, file_content, expected): if file_content: toml_file = tmp_path / "foo.toml" toml_file.write_text(file_content) - cli_config["config_file"] = expected["config_file"] = str(toml_file) - else: - cli_config["config_file"] = expected["config_file"] = None + argv.expand(["--config-file", str(toml_file)]) - parser = mocker.Mock() - parser.parse_args().__dict__ = cli_config - assert get_config(parser, argv=[], defaults=defaults, tool=tool) == expected + parser = argparse.ArgumentParser() + parser.add_argument("-a", type=int, default=None) + parser.add_argument("-b", type=int, default=None) + parser.add_argument("-c", type=int, default=None) + parser.add_argument("--config-file", type=str, default=None) + assert get_config(parser, argv=argv, tool=tool) == expected From bd67dc828ca2cbcde09227c7e9741fbd31c00f89 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Sun, 18 May 2025 13:59:45 -0400 Subject: [PATCH 3/6] WIP --- diff_cover/config_parser.py | 76 +++++++-------------------------- diff_cover/diff_cover_tool.py | 9 +--- diff_cover/diff_quality_tool.py | 9 +--- poetry.lock | 20 ++++++++- pyproject.toml | 1 + tests/test_config_parser.py | 32 +++++++------- 6 files changed, 55 insertions(+), 92 deletions(-) diff --git a/diff_cover/config_parser.py b/diff_cover/config_parser.py index 6610c422..966d80bb 100644 --- a/diff_cover/config_parser.py +++ b/diff_cover/config_parser.py @@ -1,74 +1,28 @@ import abc import enum +import configargparse -try: - import tomli as toml - - _HAS_TOML = True -except ImportError: # pragma: no cover - _HAS_TOML = False - -if not _HAS_TOML: - try: - import tomllib as toml - - _HAS_TOML = True - except ImportError: # pragma: no cover - pass +CONFIG_FILE_HELP = "The configuration file to use" class Tool(enum.Enum): DIFF_COVER = enum.auto() DIFF_QUALITY = enum.auto() -class ParserError(Exception): - pass - - -class ConfigParser(abc.ABC): - def __init__(self, file_name, tool): - self._file_name = file_name - self._tool = tool - - @abc.abstractmethod - def parse(self): - """Returns a dict of the parsed data or None if the file cannot be handled.""" - - -class TOMLParser(ConfigParser): - def __init__(self, file_name, tool): - super().__init__(file_name, tool) - self._section = "diff_cover" if tool == Tool.DIFF_COVER else "diff_quality" - - def parse(self): - if not self._file_name.endswith(".toml"): - return None - - if not _HAS_TOML: - raise ParserError("No Toml lib installed") - - with open(self._file_name, "rb") as file_handle: - config = toml.load(file_handle) - - config = config.get("tool", {}).get(self._section, {}) - if not config: - raise ParserError(f"No 'tool.{self._section}' configuration available") - return config - - -_PARSERS = [TOMLParser] - - -def _parse_config_file(file_name, tool): - for parser_class in _PARSERS: - parser = parser_class(file_name, tool) - config = parser.parse() - if config: - return config - - raise ParserError(f"No config parser could handle {file_name}") - +def get_parser(description): + sections = ['tool.diff_cover', 'tool:diff_cover', 'diff_cover'] + parser = configargparse.ArgParser( + description=description, + default_config_files=['pyproject.toml'], + config_file_parser_class=configargparse.CompositeConfigParser( + [configargparse.TomlConfigParser(sections),] + ), + ) + parser.add_argument( + "-c", "--config-file", help=CONFIG_FILE_HELP, is_config_file=True, metavar="CONFIG_FILE" + ) + return parser def get_config(parser, argv, tool): cli_config = vars(parser.parse_args(argv)) diff --git a/diff_cover/diff_cover_tool.py b/diff_cover/diff_cover_tool.py index 94ab26db..13e48137 100644 --- a/diff_cover/diff_cover_tool.py +++ b/diff_cover/diff_cover_tool.py @@ -6,7 +6,7 @@ import xml.etree.ElementTree as etree from diff_cover import DESCRIPTION, VERSION -from diff_cover.config_parser import Tool, get_config +from diff_cover.config_parser import Tool, get_config, get_parser from diff_cover.diff_reporter import GitDiffReporter from diff_cover.git_diff import GitDiffFileTool, GitDiffTool from diff_cover.git_path import GitPathTool @@ -43,7 +43,6 @@ "Append missing lines in coverage reports based on the hits of the previous line." ) INCLUDE_UNTRACKED_HELP = "Include untracked files" -CONFIG_FILE_HELP = "The configuration file to use" DIFF_FILE_HELP = "The diff file to use" LOGGER = logging.getLogger(__name__) @@ -65,7 +64,7 @@ def parse_coverage_args(argv): The path strings may or may not exist. """ - parser = argparse.ArgumentParser(description=DESCRIPTION) + parser = get_parser(description=DESCRIPTION) parser.add_argument("coverage_file", type=str, help=COVERAGE_FILE_HELP, nargs="+") @@ -177,10 +176,6 @@ def parse_coverage_args(argv): "-q", "--quiet", action="store_true", default=False, help=QUIET_HELP ) - parser.add_argument( - "-c", "--config-file", help=CONFIG_FILE_HELP, metavar="CONFIG_FILE" - ) - parser.add_argument("--diff-file", type=str, default=None, help=DIFF_FILE_HELP) return get_config(parser=parser, argv=argv, tool=Tool.DIFF_COVER) diff --git a/diff_cover/diff_quality_tool.py b/diff_cover/diff_quality_tool.py index 29cae601..5ecb99f0 100644 --- a/diff_cover/diff_quality_tool.py +++ b/diff_cover/diff_quality_tool.py @@ -12,10 +12,9 @@ import diff_cover from diff_cover import hookspecs -from diff_cover.config_parser import Tool, get_config +from diff_cover.config_parser import Tool, get_config, get_parser from diff_cover.diff_cover_tool import ( COMPARE_BRANCH_HELP, - CONFIG_FILE_HELP, CSS_FILE_HELP, DIFF_RANGE_NOTATION_HELP, EXCLUDE_HELP, @@ -98,7 +97,7 @@ def parse_quality_args(argv): where `HTML_REPORT` and `CSS_FILE` are paths. """ - parser = argparse.ArgumentParser(description=diff_cover.QUALITY_DESCRIPTION) + parser = get_parser(diff_cover.QUALITY_DESCRIPTION) parser.add_argument( "--violations", metavar="TOOL", type=str, help=VIOLATION_CMD_HELP, required=True @@ -198,10 +197,6 @@ def parse_quality_args(argv): "-q", "--quiet", action="store_true", default=False, help=QUIET_HELP ) - parser.add_argument( - "-c", "--config-file", help=CONFIG_FILE_HELP, metavar="CONFIG_FILE" - ) - parser.add_argument( "--report-root-path", help=REPORT_ROOT_PATH_HELP, metavar="ROOT_PATH" ) diff --git a/poetry.lock b/poetry.lock index 42e1510e..775540c0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. [[package]] name = "astroid" @@ -102,6 +102,22 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "configargparse" +version = "1.7" +description = "A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables." +optional = false +python-versions = ">=3.5" +groups = ["main"] +files = [ + {file = "ConfigArgParse-1.7-py3-none-any.whl", hash = "sha256:d249da6591465c6c26df64a9f73d2536e743be2f244eb3ebe61114af2f94f86b"}, + {file = "ConfigArgParse-1.7.tar.gz", hash = "sha256:e7067471884de5478c58a511e529f0f9bd1c66bfef1dea90935438d6c23306d1"}, +] + +[package.extras] +test = ["PyYAML", "mock", "pytest"] +yaml = ["PyYAML"] + [[package]] name = "coverage" version = "7.6.12" @@ -829,4 +845,4 @@ toml = ["tomli"] [metadata] lock-version = "2.1" python-versions = "^3.9.17" -content-hash = "2815c3254c5063b104943c66b28aefaaed2682e4019602e066de693a06af422c" +content-hash = "4c5ec4557ffd494a7897f73040170362cc1d964025763f8ce64ec3c49006b439" diff --git a/pyproject.toml b/pyproject.toml index 13cf3d72..5041232a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,7 @@ Jinja2 = ">=2.7.1" pluggy = ">=0.13.1,<2" chardet = ">=3.0.0" tomli = {version = ">=1.2.1", optional = true} +configargparse = "^1.7" [tool.poetry.group.dev.dependencies] pytest-cov = "^6.1.1" diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index 7591b6e1..65a86efe 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -2,7 +2,7 @@ import argparse from diff_cover import config_parser -from diff_cover.config_parser import ParserError, TOMLParser, Tool, get_config +from diff_cover.config_parser import ParserError, TOMLParser, Tool, get_config, get_parser tools = pytest.mark.parametrize("tool", list(Tool)) @@ -65,21 +65,21 @@ def test_get_config_unrecognized_file(mocker, tool): [ ( Tool.DIFF_COVER, - ["-a", 2], + ["-aa", "2"], None, - {"a": 2, "b": None, "c": None}, + {"aa": 2, "bb": None, "cc": None}, ), ( Tool.DIFF_QUALITY, - ["-a", 3], + ["-aa", "3"], None, - {"a": 3, "b": None, "c": None}, + {"aa": 3, "bb": None, "cc": None}, ), ( Tool.DIFF_COVER, - ["-a", 2, "c", 1], - "[tool.diff_cover]\na=1\nb=6", - {"a": 2, "b": 6, "c": 1}, + ["-aa", "2", "-cc", "1"], + "[tool.diff_cover]\naa=1\nbb=6", + {"aa": 2, "bb": 6, "cc": 1}, ), ], ) @@ -87,11 +87,13 @@ def test_get_config(tmp_path, tool, argv, file_content, expected): if file_content: toml_file = tmp_path / "foo.toml" toml_file.write_text(file_content) - argv.expand(["--config-file", str(toml_file)]) + argv.extend(["--config-file", str(toml_file)]) - parser = argparse.ArgumentParser() - parser.add_argument("-a", type=int, default=None) - parser.add_argument("-b", type=int, default=None) - parser.add_argument("-c", type=int, default=None) - parser.add_argument("--config-file", type=str, default=None) - assert get_config(parser, argv=argv, tool=tool) == expected + parser = get_parser(description="test") + parser.add_argument("-aa", type=int, default=0) + parser.add_argument("-bb", type=int, default=0) + parser.add_argument("-cc", type=int, default=0) + import ipdb; ipdb.set_trace() + actual = get_config(parser, argv=argv, tool=tool) + actual.pop("config_file") + assert actual == expected From 2e638b3c3630786115ac2bf9534707f729a0f4ae Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Fri, 6 Jun 2025 14:52:45 -0400 Subject: [PATCH 4/6] . --- diff_cover/config_parser.py | 18 +++++++++++++----- diff_cover/diff_quality_tool.py | 2 +- tests/test_config_parser.py | 12 +++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/diff_cover/config_parser.py b/diff_cover/config_parser.py index 966d80bb..43e76c77 100644 --- a/diff_cover/config_parser.py +++ b/diff_cover/config_parser.py @@ -1,29 +1,37 @@ import abc import enum -import configargparse +import configargparse CONFIG_FILE_HELP = "The configuration file to use" + class Tool(enum.Enum): DIFF_COVER = enum.auto() DIFF_QUALITY = enum.auto() def get_parser(description): - sections = ['tool.diff_cover', 'tool:diff_cover', 'diff_cover'] + sections = ["tool.diff_cover", "tool:diff_cover", "diff_cover"] parser = configargparse.ArgParser( description=description, - default_config_files=['pyproject.toml'], + default_config_files=["pyproject.toml"], config_file_parser_class=configargparse.CompositeConfigParser( - [configargparse.TomlConfigParser(sections),] + [ + configargparse.TomlConfigParser(sections), + ] ), ) parser.add_argument( - "-c", "--config-file", help=CONFIG_FILE_HELP, is_config_file=True, metavar="CONFIG_FILE" + "-c", + "--config-file", + help=CONFIG_FILE_HELP, + is_config_file=True, + metavar="CONFIG_FILE", ) return parser + def get_config(parser, argv, tool): cli_config = vars(parser.parse_args(argv)) if cli_config["config_file"]: diff --git a/diff_cover/diff_quality_tool.py b/diff_cover/diff_quality_tool.py index e425def8..6d136ee2 100644 --- a/diff_cover/diff_quality_tool.py +++ b/diff_cover/diff_quality_tool.py @@ -102,7 +102,7 @@ def parse_quality_args(argv): where `HTML_REPORT` and `CSS_FILE` are paths. """ - parser = get_parser(diff_cover.QUALITY_DESCRIPTION) + parser = get_parser(diff_cover.QUALITY_DESCRIPTION) parser.add_argument( "--violations", metavar="TOOL", type=str, help=VIOLATION_CMD_HELP, required=True diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index 65a86efe..df9899a5 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -1,8 +1,15 @@ -import pytest import argparse +import pytest + from diff_cover import config_parser -from diff_cover.config_parser import ParserError, TOMLParser, Tool, get_config, get_parser +from diff_cover.config_parser import ( + ParserError, + TOMLParser, + Tool, + get_config, + get_parser, +) tools = pytest.mark.parametrize("tool", list(Tool)) @@ -93,7 +100,6 @@ def test_get_config(tmp_path, tool, argv, file_content, expected): parser.add_argument("-aa", type=int, default=0) parser.add_argument("-bb", type=int, default=0) parser.add_argument("-cc", type=int, default=0) - import ipdb; ipdb.set_trace() actual = get_config(parser, argv=argv, tool=tool) actual.pop("config_file") assert actual == expected From 2a8ea49ef1812b90ea6a66d632493187c863a273 Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Thu, 12 Jun 2025 14:37:48 -0400 Subject: [PATCH 5/6] wip --- diff_cover/config_parser.py | 9 +- diff_cover/diff_cover_tool.py | 18 ++-- poetry.lock | 62 ++++++------- tests/test_config_parser.py | 164 +++++++++++++++++----------------- 4 files changed, 129 insertions(+), 124 deletions(-) diff --git a/diff_cover/config_parser.py b/diff_cover/config_parser.py index 43e76c77..c7bae775 100644 --- a/diff_cover/config_parser.py +++ b/diff_cover/config_parser.py @@ -33,11 +33,12 @@ def get_parser(description): def get_config(parser, argv, tool): + import ipdb; ipdb.set_trace() cli_config = vars(parser.parse_args(argv)) - if cli_config["config_file"]: - file_config = _parse_config_file(cli_config["config_file"], tool) - else: - file_config = {} + # if cli_config["config_file"]: + # file_config = _parse_config_file(cli_config["config_file"], tool) + # else: + file_config = {} config = {} for config_dict in [file_config, cli_config]: diff --git a/diff_cover/diff_cover_tool.py b/diff_cover/diff_cover_tool.py index 5939ee44..d352be3f 100644 --- a/diff_cover/diff_cover_tool.py +++ b/diff_cover/diff_cover_tool.py @@ -22,21 +22,24 @@ XmlCoverageReporter, ) -HTML_REPORT_HELP = "Diff coverage HTML output" -JSON_REPORT_HELP = "Diff coverage JSON output" -MARKDOWN_REPORT_HELP = "Diff coverage Markdown output" -COMPARE_BRANCH_HELP = "Branch to compare (default: %(default)s)" +FORMAT_HELP = "Format to use" +HTML_REPORT_DEFAULT_PATH = "diff-cover.html" +JSON_REPORT_DEFAULT_PATH = "diff-cover.json" +MARKDOWN_REPORT_DEFAULT_PATH = "diff-cover.md" +COMPARE_BRANCH_HELP = "Branch to compare" CSS_FILE_HELP = "Write CSS into an external file" -FAIL_UNDER_HELP = "Returns an error code if coverage or quality score is below this value (default: %(default)s)" +FAIL_UNDER_HELP = ( + "Returns an error code if coverage or quality score is below this value" +) IGNORE_STAGED_HELP = "Ignores staged changes" IGNORE_UNSTAGED_HELP = "Ignores unstaged changes" IGNORE_WHITESPACE = "When getting a diff ignore any and all whitespace" EXCLUDE_HELP = "Exclude files, more patterns supported" INCLUDE_HELP = "Files to include (glob pattern)" -SRC_ROOTS_HELP = "List of source directories (only for jacoco coverage reports) (default: %(default)s)" +SRC_ROOTS_HELP = "List of source directories (only for jacoco coverage reports)" COVERAGE_FILE_HELP = "coverage report (XML or lcov.info)" DIFF_RANGE_NOTATION_HELP = ( - "Git diff range notation to use when comparing branches (default: '%(default)s')" + "Git diff range notation to use when comparing branches, defaults to '...'" ) QUIET_HELP = "Only print errors and failures" SHOW_UNCOVERED = "Show uncovered lines on the console" @@ -44,6 +47,7 @@ "Append missing lines in coverage reports based on the hits of the previous line." ) INCLUDE_UNTRACKED_HELP = "Include untracked files" +CONFIG_FILE_HELP = "The configuration file to use" DIFF_FILE_HELP = "The diff file to use" LOGGER = logging.getLogger(__name__) diff --git a/poetry.lock b/poetry.lock index aec02548..07c24451 100644 --- a/poetry.lock +++ b/poetry.lock @@ -121,14 +121,14 @@ files = [ [[package]] name = "configargparse" -version = "1.7" +version = "1.7.1" description = "A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables." optional = false -python-versions = ">=3.5" +python-versions = ">=3.6" groups = ["main"] files = [ - {file = "ConfigArgParse-1.7-py3-none-any.whl", hash = "sha256:d249da6591465c6c26df64a9f73d2536e743be2f244eb3ebe61114af2f94f86b"}, - {file = "ConfigArgParse-1.7.tar.gz", hash = "sha256:e7067471884de5478c58a511e529f0f9bd1c66bfef1dea90935438d6c23306d1"}, + {file = "configargparse-1.7.1-py3-none-any.whl", hash = "sha256:8b586a31f9d873abd1ca527ffbe58863c99f36d896e2829779803125e83be4b6"}, + {file = "configargparse-1.7.1.tar.gz", hash = "sha256:79c2ddae836a1e5914b71d58e4b9adbd9f7779d4e6351a637b7d2d9b6c46d3d9"}, ] [package.extras] @@ -677,14 +677,14 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] [[package]] name = "pytest-datadir" -version = "1.7.1" +version = "1.7.2" description = "pytest plugin for test data directories and files" optional = false python-versions = ">=3.8" groups = ["dev"] files = [ - {file = "pytest_datadir-1.7.1-py3-none-any.whl", hash = "sha256:12372417ff2cec4db8aecaf6b6fac119db91515f17e81c7926220e342148e3b4"}, - {file = "pytest_datadir-1.7.1.tar.gz", hash = "sha256:367b4cd34b6ca3151317db310ab688ef9a28a9ec15e1e7d6696f4737b5f14bd8"}, + {file = "pytest_datadir-1.7.2-py3-none-any.whl", hash = "sha256:8392ba0e9eaf37030e663dcd91cc5123dec99c44300f0c5eac44f35f13f0e086"}, + {file = "pytest_datadir-1.7.2.tar.gz", hash = "sha256:15f5228a35d0a3205e4968e75d3b9cca91762424e1eafc21eb637d380a48443e"}, ] [package.dependencies] @@ -749,30 +749,30 @@ docutils = ">=0.11,<1.0" [[package]] name = "ruff" -version = "0.11.12" +version = "0.11.13" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" groups = ["dev"] files = [ - {file = "ruff-0.11.12-py3-none-linux_armv6l.whl", hash = "sha256:c7680aa2f0d4c4f43353d1e72123955c7a2159b8646cd43402de6d4a3a25d7cc"}, - {file = "ruff-0.11.12-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:2cad64843da9f134565c20bcc430642de897b8ea02e2e79e6e02a76b8dcad7c3"}, - {file = "ruff-0.11.12-py3-none-macosx_11_0_arm64.whl", hash = "sha256:9b6886b524a1c659cee1758140138455d3c029783d1b9e643f3624a5ee0cb0aa"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3cc3a3690aad6e86c1958d3ec3c38c4594b6ecec75c1f531e84160bd827b2012"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f97fdbc2549f456c65b3b0048560d44ddd540db1f27c778a938371424b49fe4a"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:74adf84960236961090e2d1348c1a67d940fd12e811a33fb3d107df61eef8fc7"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b56697e5b8bcf1d61293ccfe63873aba08fdbcbbba839fc046ec5926bdb25a3a"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4d47afa45e7b0eaf5e5969c6b39cbd108be83910b5c74626247e366fd7a36a13"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:692bf9603fe1bf949de8b09a2da896f05c01ed7a187f4a386cdba6760e7f61be"}, - {file = "ruff-0.11.12-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:08033320e979df3b20dba567c62f69c45e01df708b0f9c83912d7abd3e0801cd"}, - {file = "ruff-0.11.12-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:929b7706584f5bfd61d67d5070f399057d07c70585fa8c4491d78ada452d3bef"}, - {file = "ruff-0.11.12-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:7de4a73205dc5756b8e09ee3ed67c38312dce1aa28972b93150f5751199981b5"}, - {file = "ruff-0.11.12-py3-none-musllinux_1_2_i686.whl", hash = "sha256:2635c2a90ac1b8ca9e93b70af59dfd1dd2026a40e2d6eebaa3efb0465dd9cf02"}, - {file = "ruff-0.11.12-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:d05d6a78a89166f03f03a198ecc9d18779076ad0eec476819467acb401028c0c"}, - {file = "ruff-0.11.12-py3-none-win32.whl", hash = "sha256:f5a07f49767c4be4772d161bfc049c1f242db0cfe1bd976e0f0886732a4765d6"}, - {file = "ruff-0.11.12-py3-none-win_amd64.whl", hash = "sha256:5a4d9f8030d8c3a45df201d7fb3ed38d0219bccd7955268e863ee4a115fa0832"}, - {file = "ruff-0.11.12-py3-none-win_arm64.whl", hash = "sha256:65194e37853158d368e333ba282217941029a28ea90913c67e558c611d04daa5"}, - {file = "ruff-0.11.12.tar.gz", hash = "sha256:43cf7f69c7d7c7d7513b9d59c5d8cafd704e05944f978614aa9faff6ac202603"}, + {file = "ruff-0.11.13-py3-none-linux_armv6l.whl", hash = "sha256:4bdfbf1240533f40042ec00c9e09a3aade6f8c10b6414cf11b519488d2635d46"}, + {file = "ruff-0.11.13-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:aef9c9ed1b5ca28bb15c7eac83b8670cf3b20b478195bd49c8d756ba0a36cf48"}, + {file = "ruff-0.11.13-py3-none-macosx_11_0_arm64.whl", hash = "sha256:53b15a9dfdce029c842e9a5aebc3855e9ab7771395979ff85b7c1dedb53ddc2b"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab153241400789138d13f362c43f7edecc0edfffce2afa6a68434000ecd8f69a"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6c51f93029d54a910d3d24f7dd0bb909e31b6cd989a5e4ac513f4eb41629f0dc"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1808b3ed53e1a777c2ef733aca9051dc9bf7c99b26ece15cb59a0320fbdbd629"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d28ce58b5ecf0f43c1b71edffabe6ed7f245d5336b17805803312ec9bc665933"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:55e4bc3a77842da33c16d55b32c6cac1ec5fb0fbec9c8c513bdce76c4f922165"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:633bf2c6f35678c56ec73189ba6fa19ff1c5e4807a78bf60ef487b9dd272cc71"}, + {file = "ruff-0.11.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4ffbc82d70424b275b089166310448051afdc6e914fdab90e08df66c43bb5ca9"}, + {file = "ruff-0.11.13-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a9ddd3ec62a9a89578c85842b836e4ac832d4a2e0bfaad3b02243f930ceafcc"}, + {file = "ruff-0.11.13-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d237a496e0778d719efb05058c64d28b757c77824e04ffe8796c7436e26712b7"}, + {file = "ruff-0.11.13-py3-none-musllinux_1_2_i686.whl", hash = "sha256:26816a218ca6ef02142343fd24c70f7cd8c5aa6c203bca284407adf675984432"}, + {file = "ruff-0.11.13-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:51c3f95abd9331dc5b87c47ac7f376db5616041173826dfd556cfe3d4977f492"}, + {file = "ruff-0.11.13-py3-none-win32.whl", hash = "sha256:96c27935418e4e8e77a26bb05962817f28b8ef3843a6c6cc49d8783b5507f250"}, + {file = "ruff-0.11.13-py3-none-win_amd64.whl", hash = "sha256:29c3189895a8a6a657b7af4e97d330c8a3afd2c9c8f46c81e2fc5a31866517e3"}, + {file = "ruff-0.11.13-py3-none-win_arm64.whl", hash = "sha256:b4385285e9179d608ff1d2fb9922062663c658605819a6876d8beef0c30b7f3b"}, + {file = "ruff-0.11.13.tar.gz", hash = "sha256:26fa247dc68d1d4e72c179e08889a25ac0c7ba4d78aecfc835d49cbfd60bf514"}, ] [[package]] @@ -868,14 +868,14 @@ markers = {main = "extra == \"toml\"", dev = "python_version < \"3.11\""} [[package]] name = "tomlkit" -version = "0.13.2" +version = "0.13.3" description = "Style preserving TOML library" optional = false python-versions = ">=3.8" groups = ["dev"] files = [ - {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, - {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, + {file = "tomlkit-0.13.3-py3-none-any.whl", hash = "sha256:c89c649d79ee40629a9fda55f8ace8c6a1b42deb912b2a8fd8d942ddadb606b0"}, + {file = "tomlkit-0.13.3.tar.gz", hash = "sha256:430cf247ee57df2b94ee3fbe588e71d362a941ebb545dec29b53961d61add2a1"}, ] [[package]] @@ -896,5 +896,5 @@ toml = ["tomli"] [metadata] lock-version = "2.1" -python-versions = "^3.9.17" -content-hash = "4c5ec4557ffd494a7897f73040170362cc1d964025763f8ce64ec3c49006b439" +python-versions = ">=3.9" +content-hash = "c4a47c4a86367765a0f410818f344aa7231d25e95f6fa0bc0634d8229c6a017c" diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index df9899a5..68756a0e 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -4,102 +4,102 @@ from diff_cover import config_parser from diff_cover.config_parser import ( - ParserError, - TOMLParser, + # ParserError, + # TOMLParser, Tool, - get_config, + # get_config, get_parser, ) tools = pytest.mark.parametrize("tool", list(Tool)) -class TestTOMLParser: - @tools - def test_parse_no_toml_file(self, tool): - parser = TOMLParser("myfile", tool) - assert parser.parse() is None +# class TestTOMLParser: +# @tools +# def test_parse_no_toml_file(self, tool): +# parser = TOMLParser("myfile", tool) +# assert parser.parse() is None - @tools - def test_parse_but_no_tomli_installed(self, tool, mocker): - mocker.patch.object(config_parser, "_HAS_TOML", False) - parser = TOMLParser("myfile.toml", tool) - with pytest.raises(ParserError): - parser.parse() +# @tools +# def test_parse_but_no_tomli_installed(self, tool, mocker): +# mocker.patch.object(config_parser, "_HAS_TOML", False) +# parser = TOMLParser("myfile.toml", tool) +# with pytest.raises(ParserError): +# parser.parse() - @pytest.mark.parametrize( - "tool,content", - [ - (Tool.DIFF_COVER, ""), - (Tool.DIFF_COVER, "[tool.diff_quality]"), - (Tool.DIFF_QUALITY, ""), - (Tool.DIFF_COVER, "[tool.diff_cover]"), - ], - ) - def test_parse_but_no_data(self, tool, content, tmp_path): - toml_file = tmp_path / "foo.toml" - toml_file.write_text(content) +# @pytest.mark.parametrize( +# "tool,content", +# [ +# (Tool.DIFF_COVER, ""), +# (Tool.DIFF_COVER, "[tool.diff_quality]"), +# (Tool.DIFF_QUALITY, ""), +# (Tool.DIFF_COVER, "[tool.diff_cover]"), +# ], +# ) +# def test_parse_but_no_data(self, tool, content, tmp_path): +# toml_file = tmp_path / "foo.toml" +# toml_file.write_text(content) - parser = TOMLParser(str(toml_file), tool) - with pytest.raises(ParserError): - parser.parse() +# parser = TOMLParser(str(toml_file), tool) +# with pytest.raises(ParserError): +# parser.parse() - @pytest.mark.parametrize( - "tool,content,expected", - [ - (Tool.DIFF_COVER, "[tool.diff_cover]\nquiet=true", {"quiet": True}), - (Tool.DIFF_QUALITY, "[tool.diff_quality]\nquiet=true", {"quiet": True}), - ], - ) - def test_parse(self, tool, content, tmp_path, expected): - toml_file = tmp_path / "foo.toml" - toml_file.write_text(content) +# @pytest.mark.parametrize( +# "tool,content,expected", +# [ +# (Tool.DIFF_COVER, "[tool.diff_cover]\nquiet=true", {"quiet": True}), +# (Tool.DIFF_QUALITY, "[tool.diff_quality]\nquiet=true", {"quiet": True}), +# ], +# ) +# def test_parse(self, tool, content, tmp_path, expected): +# toml_file = tmp_path / "foo.toml" +# toml_file.write_text(content) - parser = TOMLParser(str(toml_file), tool) - assert parser.parse() == expected +# parser = TOMLParser(str(toml_file), tool) +# assert parser.parse() == expected -@tools -def test_get_config_unrecognized_file(mocker, tool): - parser = mocker.Mock() - parser.parse_args().__dict__ = {"config_file": "foo.bar"} - with pytest.raises(ParserError): - get_config(parser, argv=[], tool=tool) +# @tools +# def test_get_config_unrecognized_file(mocker, tool): +# parser = mocker.Mock() +# parser.parse_args().__dict__ = {"config_file": "foo.bar"} +# with pytest.raises(ParserError): +# get_config(parser, argv=[], tool=tool) -@pytest.mark.parametrize( - "tool,argv,file_content,expected", - [ - ( - Tool.DIFF_COVER, - ["-aa", "2"], - None, - {"aa": 2, "bb": None, "cc": None}, - ), - ( - Tool.DIFF_QUALITY, - ["-aa", "3"], - None, - {"aa": 3, "bb": None, "cc": None}, - ), - ( - Tool.DIFF_COVER, - ["-aa", "2", "-cc", "1"], - "[tool.diff_cover]\naa=1\nbb=6", - {"aa": 2, "bb": 6, "cc": 1}, - ), - ], -) -def test_get_config(tmp_path, tool, argv, file_content, expected): - if file_content: - toml_file = tmp_path / "foo.toml" - toml_file.write_text(file_content) - argv.extend(["--config-file", str(toml_file)]) +# @pytest.mark.parametrize( +# "tool,argv,file_content,expected", +# [ +# ( +# Tool.DIFF_COVER, +# ["-aa", "2"], +# None, +# {"aa": 2, "bb": None, "cc": None}, +# ), +# ( +# Tool.DIFF_QUALITY, +# ["-aa", "3"], +# None, +# {"aa": 3, "bb": None, "cc": None}, +# ), +# ( +# Tool.DIFF_COVER, +# ["-aa", "2", "-cc", "1"], +# "[tool.diff_cover]\naa=1\nbb=6", +# {"aa": 2, "bb": 6, "cc": 1}, +# ), +# ], +# ) +# def test_get_config(tmp_path, tool, argv, file_content, expected): +# if file_content: +# toml_file = tmp_path / "foo.toml" +# toml_file.write_text(file_content) +# argv.extend(["--config-file", str(toml_file)]) - parser = get_parser(description="test") - parser.add_argument("-aa", type=int, default=0) - parser.add_argument("-bb", type=int, default=0) - parser.add_argument("-cc", type=int, default=0) - actual = get_config(parser, argv=argv, tool=tool) - actual.pop("config_file") - assert actual == expected +# parser = get_parser(description="test") +# parser.add_argument("-aa", type=int, default=0) +# parser.add_argument("-bb", type=int, default=0) +# parser.add_argument("-cc", type=int, default=0) +# actual = get_config(parser, argv=argv, tool=tool) +# actual.pop("config_file") +# assert actual == expected From eac42ee1f9ac7d8bcd44de34922c5abbc0343b0d Mon Sep 17 00:00:00 2001 From: kingbuzzman Date: Sun, 15 Jun 2025 15:14:31 -0400 Subject: [PATCH 6/6] wip --- diff_cover/config_parser.py | 1 - tests/test_config_parser.py | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/diff_cover/config_parser.py b/diff_cover/config_parser.py index c7bae775..2d0f1d29 100644 --- a/diff_cover/config_parser.py +++ b/diff_cover/config_parser.py @@ -33,7 +33,6 @@ def get_parser(description): def get_config(parser, argv, tool): - import ipdb; ipdb.set_trace() cli_config = vars(parser.parse_args(argv)) # if cli_config["config_file"]: # file_config = _parse_config_file(cli_config["config_file"], tool) diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index 68756a0e..56b9085e 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -3,13 +3,7 @@ import pytest from diff_cover import config_parser -from diff_cover.config_parser import ( - # ParserError, - # TOMLParser, - Tool, - # get_config, - get_parser, -) +from diff_cover.config_parser import Tool tools = pytest.mark.parametrize("tool", list(Tool))