diff --git a/doc/whatsnew/fragments/8935.other b/doc/whatsnew/fragments/8935.other new file mode 100644 index 0000000000..f105c8eb11 --- /dev/null +++ b/doc/whatsnew/fragments/8935.other @@ -0,0 +1,3 @@ +Print how many files were checked in verbose mode. + +Closes #8935 diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index e21d8b5d97..3fc3e59ed5 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -1080,7 +1080,7 @@ def open(self) -> None: ) self.stats.reset_message_count() - def generate_reports(self) -> int | None: + def generate_reports(self, verbose: bool = False) -> int | None: """Close the whole package /module, it's time to make reports ! if persistent run, pickle results for later comparison @@ -1098,7 +1098,7 @@ def generate_reports(self) -> int | None: if self.config.reports: self.reporter.display_reports(sect) - score_value = self._report_evaluation() + score_value = self._report_evaluation(verbose) # save results if persistent run if self.config.persistent: save_results(self.stats, self.file_state.base_name) @@ -1107,7 +1107,7 @@ def generate_reports(self) -> int | None: score_value = None return score_value - def _report_evaluation(self) -> int | None: + def _report_evaluation(self, verbose: bool = False) -> int | None: """Make the global evaluation report.""" # check with at least a statement (usually 0 when there is a # syntax error preventing pylint from further processing) @@ -1139,6 +1139,11 @@ def _report_evaluation(self) -> int | None: if pnote is not None: msg += f" (previous run: {pnote:.2f}/10, {note - pnote:+.2f})" + if verbose: + checked_files_count = self.stats.node_count["module"] + unchecked_files_count = self.stats.undocumented["module"] + msg += f"\nChecked {checked_files_count} files, skipped {unchecked_files_count} files" + if self.config.score: sect = report_nodes.EvaluationSection(msg) self.reporter.display_reports(sect) diff --git a/pylint/lint/run.py b/pylint/lint/run.py index e7a0fde8e6..1a8d594a04 100644 --- a/pylint/lint/run.py +++ b/pylint/lint/run.py @@ -203,13 +203,13 @@ def __init__( with open(self._output, "w", encoding="utf-8") as output: linter.reporter.out = output linter.check(args) - score_value = linter.generate_reports() + score_value = linter.generate_reports(verbose=self.verbose) except OSError as ex: print(ex, file=sys.stderr) sys.exit(32) else: linter.check(args) - score_value = linter.generate_reports() + score_value = linter.generate_reports(verbose=self.verbose) if linter.config.clear_cache_post_run: clear_lru_caches() MANAGER.clear_cache() diff --git a/tests/test_self.py b/tests/test_self.py index 159d3960e1..023fbd8c99 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -218,6 +218,11 @@ def test_disable_all(self) -> None: self._runtest([UNNECESSARY_LAMBDA, "--disable=all"], out=out, code=32) assert "No files to lint: exiting." in out.getvalue().strip() + def test_output_with_verbose(self) -> None: + out = StringIO() + self._runtest([UNNECESSARY_LAMBDA, "--verbose"], out=out, code=4) + assert "Checked 1 files, skipped 0 files" in out.getvalue().strip() + def test_no_out_encoding(self) -> None: """Test redirection of stdout with non ascii characters.""" # This test reproduces bug #48066 ; it happens when stdout is redirected