Skip to content

Commit

Permalink
Exit immediately if all messages are disabled (#8799)
Browse files Browse the repository at this point in the history
Don't print help
  • Loading branch information
jacobtylerwalls authored Jun 26, 2023
1 parent b9ed113 commit d203de7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/8715.performance
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Exit immediately if all messages are disabled.

Closes #8715
8 changes: 5 additions & 3 deletions pylint/lint/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ def __init__(
sys.exit(code)
return

# Display help messages if there are no files to lint
if not args:
print(linter.help())
# Display help if there are no files to lint or no checks enabled
if not args or len(linter.config.disable) == len(
linter.msgs_store._messages_definitions
):
print("No files to lint: exiting.")
sys.exit(32)

if linter.config.jobs < 0:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ def test_nonexistent_config_file(self) -> None:
def test_error_missing_arguments(self) -> None:
self._runtest([], code=32)

def test_disable_all(self) -> None:
out = StringIO()
self._runtest([UNNECESSARY_LAMBDA, "--disable=all"], out=out, code=32)
assert "No files to lint: exiting." 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

0 comments on commit d203de7

Please sign in to comment.