Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print statistics how many files were checked in verbose #9122

Merged
merged 11 commits into from
Nov 8, 2023
26 changes: 25 additions & 1 deletion doc/whatsnew/3/3.1/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,29 @@
Summary -- Release highlights
=============================


.. towncrier release notes start

What's new in Pylint 3.1.0?
meltemkenis marked this conversation as resolved.
Show resolved Hide resolved
---------------------------
Release date: 2023-11-08


False Positives Fixed
---------------------

- Fixed false positive for ``inherit-non-class`` for generic Protocols.

Closes #9106 (`#9106 <https://github.com/pylint-dev/pylint/issues/9106>`_)



Other Changes
-------------

- Fix a crash when an enum class which is also decorated with a ``dataclasses.dataclass`` decorator is defined.

Closes #9100 (`#9100 <https://github.com/pylint-dev/pylint/issues/9100>`_)

- Printing how many files were checked in verbose.

Closes #8935 (`#8935 <https://github.com/pylint-dev/pylint/issues/8935>`_)
11 changes: 8 additions & 3 deletions pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pylint/lint/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down