Skip to content

Commit 2b17c39

Browse files
authored
Print statistics how many files were checked in verbose (#9122)
1 parent 3a4bb28 commit 2b17c39

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

doc/whatsnew/fragments/8935.other

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Print how many files were checked in verbose mode.
2+
3+
Closes #8935

pylint/lint/pylinter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ def open(self) -> None:
10801080
)
10811081
self.stats.reset_message_count()
10821082

1083-
def generate_reports(self) -> int | None:
1083+
def generate_reports(self, verbose: bool = False) -> int | None:
10841084
"""Close the whole package /module, it's time to make reports !
10851085
10861086
if persistent run, pickle results for later comparison
@@ -1098,7 +1098,7 @@ def generate_reports(self) -> int | None:
10981098

10991099
if self.config.reports:
11001100
self.reporter.display_reports(sect)
1101-
score_value = self._report_evaluation()
1101+
score_value = self._report_evaluation(verbose)
11021102
# save results if persistent run
11031103
if self.config.persistent:
11041104
save_results(self.stats, self.file_state.base_name)
@@ -1107,7 +1107,7 @@ def generate_reports(self) -> int | None:
11071107
score_value = None
11081108
return score_value
11091109

1110-
def _report_evaluation(self) -> int | None:
1110+
def _report_evaluation(self, verbose: bool = False) -> int | None:
11111111
"""Make the global evaluation report."""
11121112
# check with at least a statement (usually 0 when there is a
11131113
# syntax error preventing pylint from further processing)
@@ -1139,6 +1139,11 @@ def _report_evaluation(self) -> int | None:
11391139
if pnote is not None:
11401140
msg += f" (previous run: {pnote:.2f}/10, {note - pnote:+.2f})"
11411141

1142+
if verbose:
1143+
checked_files_count = self.stats.node_count["module"]
1144+
unchecked_files_count = self.stats.undocumented["module"]
1145+
msg += f"\nChecked {checked_files_count} files, skipped {unchecked_files_count} files"
1146+
11421147
if self.config.score:
11431148
sect = report_nodes.EvaluationSection(msg)
11441149
self.reporter.display_reports(sect)

pylint/lint/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ def __init__(
203203
with open(self._output, "w", encoding="utf-8") as output:
204204
linter.reporter.out = output
205205
linter.check(args)
206-
score_value = linter.generate_reports()
206+
score_value = linter.generate_reports(verbose=self.verbose)
207207
except OSError as ex:
208208
print(ex, file=sys.stderr)
209209
sys.exit(32)
210210
else:
211211
linter.check(args)
212-
score_value = linter.generate_reports()
212+
score_value = linter.generate_reports(verbose=self.verbose)
213213
if linter.config.clear_cache_post_run:
214214
clear_lru_caches()
215215
MANAGER.clear_cache()

tests/test_self.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ def test_disable_all(self) -> None:
218218
self._runtest([UNNECESSARY_LAMBDA, "--disable=all"], out=out, code=32)
219219
assert "No files to lint: exiting." in out.getvalue().strip()
220220

221+
def test_output_with_verbose(self) -> None:
222+
out = StringIO()
223+
self._runtest([UNNECESSARY_LAMBDA, "--verbose"], out=out, code=4)
224+
assert "Checked 1 files, skipped 0 files" in out.getvalue().strip()
225+
221226
def test_no_out_encoding(self) -> None:
222227
"""Test redirection of stdout with non ascii characters."""
223228
# This test reproduces bug #48066 ; it happens when stdout is redirected

0 commit comments

Comments
 (0)