Skip to content

Commit

Permalink
Remove constant
Browse files Browse the repository at this point in the history
Signed-off-by: Dennis Keck <[email protected]>
  • Loading branch information
fellhorn committed Jul 14, 2024
1 parent 7809902 commit 8449c81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
13 changes: 0 additions & 13 deletions pylint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,6 @@
MSG_TYPES_LONG: dict[str, str] = {v: k for k, v in MSG_TYPES.items()}

MSG_TYPES_STATUS = {"I": 0, "C": 16, "R": 8, "W": 4, "E": 2, "F": 1}
PYLINT_MSGS = [
"F0001",
"F0002",
"F0010",
"F0011",
"E0001",
"E0011",
"W0012",
"R0022",
"E0013",
"E0014",
"E0015",
]

# You probably don't want to change the MAIN_CHECKER_NAME
# This would affect rcfile generation and retro-compatibility
Expand Down
13 changes: 10 additions & 3 deletions pylint/lint/message_state_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
MSG_STATE_SCOPE_MODULE,
MSG_TYPES,
MSG_TYPES_LONG,
PYLINT_MSGS,
)
from pylint.interfaces import HIGH
from pylint.message import MessageDefinition
from pylint.typing import ManagedMessage
from pylint.typing import ManagedMessage, MessageDefinitionTuple
from pylint.utils.pragma_parser import (
OPTION_PO,
InvalidPragmaError,
Expand Down Expand Up @@ -52,6 +51,11 @@ def __init__(self, linter: PyLinter) -> None:
self._stashed_messages: defaultdict[
tuple[str, str], list[tuple[str | None, str]]
] = defaultdict(list)
self.initial_messages: dict[str, MessageDefinitionTuple] = {
k: v
for k, v in self.linter.msgs.items()
if len(v) == 3 or v[3].get("default_enabled", True)
}
"""Some messages in the options (for --enable and --disable) are encountered
too early to warn about them.
Expand Down Expand Up @@ -88,7 +92,10 @@ def _get_messages_to_set(
if not enable:
# "all" should not disable pylint's own warnings
message_definitions = list(
filter(lambda m: m.msgid not in PYLINT_MSGS, message_definitions)
filter(
lambda m: m.msgid not in self.initial_messages,
message_definitions,
)
)
return message_definitions

Expand Down
4 changes: 2 additions & 2 deletions pylint/lint/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pylint.config.config_initialization import _config_initialization
from pylint.config.exceptions import ArgumentPreprocessingError
from pylint.config.utils import _preprocess_options
from pylint.constants import PYLINT_MSGS, full_version
from pylint.constants import full_version
from pylint.lint.base_options import _make_run_options
from pylint.lint.pylinter import MANAGER, PyLinter
from pylint.reporters.base_reporter import BaseReporter
Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(
if not args or (
len(linter.config.enable) == 0
and len(linter.config.disable)
== len(linter.msgs_store.messages) - len(PYLINT_MSGS)
== len(linter.msgs_store.messages) - len(linter.initial_messages)
):
print("No files to lint: exiting.")
sys.exit(32)
Expand Down

0 comments on commit 8449c81

Please sign in to comment.