class documentation

class _MessageStateHandler: (source)

Known subclasses: pylint.lint.PyLinter

View In Hierarchy

Class that handles message disabling & enabling and processing of inline pragma's.

Method __init__ Undocumented
Method disable Disable a message for a scope.
Method disable_next Disable a message for the next line.
Method disable_noerror_messages Disable message categories other than `error` and `fatal`.
Method enable Enable a message for a scope.
Method is_message_enabled Return whether this message is enabled for the current file, line and confidence level.
Method list_messages_enabled Undocumented
Method process_tokens Process tokens from the current module to search for module/block level options.
Instance Variable linter Undocumented
Method _get_message_state_scope Returns the scope at which a message was enabled/disabled.
Method _get_messages_to_set Do some tests and find the actual messages of which the status should be set.
Method _is_one_message_enabled Checks state of a single message for the current file.
Method _register_by_id_managed_msg If the msgid is a numeric one, then register it to inform the user it could furnish instead a symbolic msgid.
Method _set_msg_status Do some tests and then iterate over message definitions to set state.
Method _set_one_msg_status Set the status of an individual message.
Instance Variable _bw_options_methods Undocumented
Instance Variable _ignore_file Undocumented
Instance Variable _msgs_state Undocumented
Instance Variable _options_methods Undocumented
Instance Variable _pragma_lineno Undocumented
Instance Variable _stashed_messages Some messages in the options (for --enable and --disable) are encountered too early to warn about them.
def __init__(self, linter: PyLinter): (source)
overridden in pylint.lint.PyLinter

Undocumented

def disable(self, msgid: str, scope: str = 'package', line: int|None = None, ignore_unknown: bool = False): (source)

Disable a message for a scope.

def disable_next(self, msgid: str, _: str = 'package', line: int|None = None, ignore_unknown: bool = False): (source)

Disable a message for the next line.

def disable_noerror_messages(self): (source)

Disable message categories other than `error` and `fatal`.

def enable(self, msgid: str, scope: str = 'package', line: int|None = None, ignore_unknown: bool = False): (source)

Enable a message for a scope.

def is_message_enabled(self, msg_descr: str, line: int|None = None, confidence: interfaces.Confidence|None = None) -> bool: (source)

Return whether this message is enabled for the current file, line and confidence level. This function can't be cached right now as the line is the line of the currently analysed file (self.file_state), if it changes, then the result for the same msg_descr/line might need to change. :param msg_descr: Either the msgid or the symbol for a MessageDefinition :param line: The line of the currently analysed file :param confidence: The confidence of the message

def list_messages_enabled(self): (source)

Undocumented

def process_tokens(self, tokens: list[tokenize.TokenInfo]): (source)

Process tokens from the current module to search for module/block level options. See func_block_disable_msg.py test case for expected behaviour.

Undocumented

def _get_message_state_scope(self, msgid: str, line: int|None = None, confidence: interfaces.Confidence|None = None) -> Literal[0, 1, 2]|None: (source)

Returns the scope at which a message was enabled/disabled.

def _get_messages_to_set(self, msgid: str, enable: bool, ignore_unknown: bool = False) -> list[MessageDefinition]: (source)

Do some tests and find the actual messages of which the status should be set.

def _is_one_message_enabled(self, msgid: str, line: int|None) -> bool: (source)

Checks state of a single message for the current file. This function can't be cached as it depends on self.file_state which can change.

def _register_by_id_managed_msg(self, msgid_or_symbol: str, line: int|None, is_disabled: bool = True): (source)

If the msgid is a numeric one, then register it to inform the user it could furnish instead a symbolic msgid.

def _set_msg_status(self, msgid: str, enable: bool, scope: str = 'package', line: int|None = None, ignore_unknown: bool = False): (source)

Do some tests and then iterate over message definitions to set state.

def _set_one_msg_status(self, scope: str, msg: MessageDefinition, line: int|None, enable: bool): (source)

Set the status of an individual message.

_bw_options_methods = (source)

Undocumented

_ignore_file: bool = (source)
overridden in pylint.lint.PyLinter

Undocumented

_msgs_state: dict[str, bool] = (source)

Undocumented

_options_methods = (source)

Undocumented

_pragma_lineno: dict[str, int] = (source)

Undocumented

overridden in pylint.lint.PyLinter

Some messages in the options (for --enable and --disable) are encountered too early to warn about them. i.e. before all option providers have been fully parsed. Thus, this dict stores option_value and msg_id needed to (later) emit the messages keyed on module names.