Skip to content

Commit

Permalink
Invert option
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Oct 17, 2022
1 parent 7026264 commit d0ced17
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions doc/exts/pylint_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MessageData(NamedTuple):
checker_module_name: str
checker_module_path: str
shared: bool = False
default_disabled: bool = False
default_enabled: bool = True


MessagesDict = Dict[str, List[MessageData]]
Expand Down Expand Up @@ -195,7 +195,7 @@ def _get_all_messages(
checker_module.__name__,
checker_module.__file__,
message.shared,
message.default_disabled,
message.default_enabled,
)
msg_type = MSG_TYPES_DOC[message.msgid[0]]
messages_dict[msg_type].append(message_data)
Expand Down Expand Up @@ -274,7 +274,7 @@ def _generate_single_message_body(message: MessageData) -> str:
*{message.definition.description}*
"""
if message.default_disabled:
if not message.default_enabled:
body += f"""
.. caution::
This message is disabled by default. To enable it, add ``{message.name}`` to the ``enable`` option.
Expand Down
2 changes: 1 addition & 1 deletion doc/whatsnew/fragments/7629.other
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Add ``default_disabled`` option to optional message dict. Disables a checker message by default.
Add ``default_enabled`` option to optional message dict. Provides an option to disable a checker message by default.
To use a disabled message, the user must enable it explicitly by adding the message to the ``enable`` option.

Refs #7629
2 changes: 1 addition & 1 deletion pylint/extensions/code_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class CodeStyleChecker(BaseChecker):
"to. This can be changed to be an augmented assign.\n"
"Disabled by default!",
{
"default_disabled": True,
"default_enabled": False,
},
),
}
Expand Down
2 changes: 1 addition & 1 deletion pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def register_checker(self, checker: checkers.BaseChecker) -> None:
if hasattr(checker, "msgs"):
self.msgs_store.register_messages_from_checker(checker)
for message in checker.messages:
if message.default_disabled:
if not message.default_enabled:
self.disable(message.msgid)
# Register the checker, but disable all of its messages.
if not getattr(checker, "enabled", True):
Expand Down
4 changes: 2 additions & 2 deletions pylint/message/message_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(
maxversion: tuple[int, int] | None = None,
old_names: list[tuple[str, str]] | None = None,
shared: bool = False,
default_disabled: bool = False,
default_enabled: bool = True,
) -> None:
self.checker_name = checker.name
self.check_msgid(msgid)
Expand All @@ -44,7 +44,7 @@ def __init__(
self.minversion = minversion
self.maxversion = maxversion
self.shared = shared
self.default_disabled = default_disabled
self.default_enabled = default_enabled
self.old_names: list[tuple[str, str]] = []
if old_names:
for old_msgid, old_symbol in old_names:
Expand Down
2 changes: 1 addition & 1 deletion pylint/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ExtraMessageOptions(TypedDict, total=False):
maxversion: tuple[int, int]
minversion: tuple[int, int]
shared: bool
default_disabled: bool
default_enabled: bool


MessageDefinitionTuple = Union[
Expand Down

0 comments on commit d0ced17

Please sign in to comment.