From e45d52d7530972f912d398213dfc950658703b56 Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Sun, 27 Aug 2023 23:23:18 -0500 Subject: [PATCH] Fix a minor bug with verbose output All files were being listed in JSON output reporting, rather than only the successful files. This would be fine if it were the intended behavior, but it is not -- the internal list being built is named "successes" and is meant to track the passing files, excluding the failing ones. --- CHANGELOG.rst | 2 ++ src/check_jsonschema/checker.py | 4 +++- src/check_jsonschema/reporter.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0b5dbf0d9..aa7903912 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,8 @@ Unreleased .. vendor-insert-here +- Fix a minor bug with the verbose output introduced in v0.26.2 + 0.26.2 ------ diff --git a/src/check_jsonschema/checker.py b/src/check_jsonschema/checker.py index daa4f8545..cf024dd6f 100644 --- a/src/check_jsonschema/checker.py +++ b/src/check_jsonschema/checker.py @@ -69,9 +69,11 @@ def _build_result(self) -> CheckResult: result.record_parse_error(path, data) else: validator = self.get_validator(path, data) + passing = True for err in validator.iter_errors(data): result.record_validation_error(path, err) - else: + passing = False + if passing: result.record_validation_success(path) return result diff --git a/src/check_jsonschema/reporter.py b/src/check_jsonschema/reporter.py index 453dd9d20..48663002c 100644 --- a/src/check_jsonschema/reporter.py +++ b/src/check_jsonschema/reporter.py @@ -199,7 +199,7 @@ def _dump_parse_errors( def report_errors(self, result: CheckResult) -> None: report_obj: dict[str, t.Any] = {"status": "fail"} if self.verbosity > 1: - report_obj["checked_paths"] = list(result.successes) + report_obj["successes"] = list(result.successes) if self.verbosity > 0: report_obj["errors"] = list(self._dump_error_map(result.validation_errors)) report_obj["parse_errors"] = list(