Skip to content

Commit

Permalink
Reduce pylint messages
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Keck <26092524+fellhorn@users.noreply.github.com>
  • Loading branch information
fellhorn committed Jun 2, 2024
1 parent 4048273 commit 3509270
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 0 additions & 6 deletions pylint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
"F0002",
"F0010",
"F0011",
"I0001",
"I0010",
"I0011",
"I0013",
"I0020",
"I0021",
"I0022",
"E0001",
"E0011",
Expand Down
4 changes: 3 additions & 1 deletion pylint/lint/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def __init__(
return

# Display help if there are no files to lint or only internal checks enabled (`--disable=all`)
if not args or set([m.msgid for m in linter.messages]) == set(PYLINT_MSGS):
if not args or len(linter.msgs_store.messages) - len(
linter.config.disable
) == len(PYLINT_MSGS):
print("No files to lint: exiting.")
sys.exit(32)

Expand Down
12 changes: 11 additions & 1 deletion tests/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,19 @@ def test_disable_all(self) -> None:
assert "No files to lint: exiting." in out.getvalue().strip()

def test_disable_all_enable_invalid(self) -> None:
# Reproduces issue #9403. If disable=all is used no error was raised for invalid messages unless
# unknown-option-value was manually enabled.
out = StringIO()
self._runtest(
[UNNECESSARY_LAMBDA, "--disable=all", "--enable=foo"], out=out, code=0
# Enable one valid message to not run into "No files to lint: exiting."
[
UNNECESSARY_LAMBDA,
"--disable=all",
"--enable=import-error",
"--enable=foo",
],
out=out,
code=0,
)
assert (
"W0012: Unknown option value for '--enable', expected a valid pylint message and got 'foo'"
Expand Down

0 comments on commit 3509270

Please sign in to comment.