Skip to content

Commit 2732e0c

Browse files
committed
Change how errors-mode is parsed
1 parent f8c2cac commit 2732e0c

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

pylint/config/callback_actions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def __call__(
257257
values: Union[str, Sequence[Any], None],
258258
option_string: Optional[str] = "--errors-only",
259259
) -> None:
260-
self.run.linter.error_mode()
260+
self.run.linter._error_mode = True
261261

262262

263263
class _LongHelpAction(_AccessRunObjectAction):

pylint/config/config_initialization.py

+2
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ def _config_initialization(
103103
linter._arg_parser.print_help()
104104
sys.exit(32)
105105

106+
linter._parse_error_mode()
107+
106108
return parsed_args_list

pylint/lint/pylinter.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,14 @@ def disable_reporters(self):
831831
for report_id, _, _ in _reporters:
832832
self.disable_report(report_id)
833833

834-
def error_mode(self):
835-
"""Error mode: enable only errors; no reports, no persistent."""
836-
self._error_mode = True
834+
def _parse_error_mode(self) -> None:
835+
"""Parse the current state of the error mode.
836+
837+
Error mode: enable only errors; no reports, no persistent.
838+
"""
839+
if not self._error_mode:
840+
return
841+
837842
self.disable_noerror_messages()
838843
self.disable("miscellaneous")
839844
self.set_option("reports", False)

tests/lint/unittest_lint.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ def test_enable_checkers(linter: PyLinter) -> None:
392392

393393
def test_errors_only(initialized_linter: PyLinter) -> None:
394394
linter = initialized_linter
395-
linter.error_mode()
395+
linter._error_mode = True
396+
linter._parse_error_mode()
396397
checkers = linter.prepare_checkers()
397398
checker_names = {c.name for c in checkers}
398399
should_not = {"design", "format", "metrics", "miscellaneous", "similarities"}

0 commit comments

Comments
 (0)