def build_message_definition(checker, msgid, msg_tuple): if implements(checker, (IRawChecker, ITokenChecker)): default_scope = WarningScope.LINE else: default_scope = WarningScope.NODE options = {} if len(msg_tuple) > 3: (msg, symbol, descr, options) = msg_tuple elif len(msg_tuple) > 2: (msg, symbol, descr) = msg_tuple else: # messages should have a symbol, but for backward compatibility # they may not. (msg, descr) = msg_tuple warnings.warn( "[pylint 0.26] description of message %s doesn't include " "a symbolic name" % msgid, DeprecationWarning, ) symbol = None options.setdefault("scope", default_scope) return MessageDefinition(checker, msgid, msg, descr, symbol, **options)
def create_message_definition_from_tuple(self, msgid, msg_tuple): if implements(self, (IRawChecker, ITokenChecker)): default_scope = WarningScope.LINE else: default_scope = WarningScope.NODE options = {} if len(msg_tuple) > 3: (msg, symbol, descr, options) = msg_tuple elif len(msg_tuple) > 2: (msg, symbol, descr) = msg_tuple else: error_msg = """Messages should have a msgid and a symbol. Something like this : "W1234": ( "message", "message-symbol", "Message description with detail.", ... ), """ raise InvalidMessageError(error_msg) options.setdefault("scope", default_scope) return MessageDefinition(self, msgid, msg, descr, symbol, **options)
def create_message_definition_from_tuple( self, msgid: str, msg_tuple: MessageDefinitionTuple) -> MessageDefinition: with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) if isinstance(self, (BaseTokenChecker, BaseRawFileChecker)): default_scope = WarningScope.LINE # TODO: 3.0: Remove deprecated if-statement elif implements(self, (IRawChecker, ITokenChecker)): warnings.warn( # pragma: no cover "Checkers should subclass BaseTokenChecker or BaseRawFileChecker " "instead of using the __implements__ mechanism. Use of __implements__ " "will no longer be supported in pylint 3.0", DeprecationWarning, ) default_scope = WarningScope.LINE # pragma: no cover else: default_scope = WarningScope.NODE options: ExtraMessageOptions = {} if len(msg_tuple) == 4: (msg, symbol, descr, options) = msg_tuple # type: ignore[misc] elif len(msg_tuple) == 3: (msg, symbol, descr) = msg_tuple # type: ignore[misc] else: error_msg = """Messages should have a msgid, a symbol and a description. Something like this : "W1234": ( "message", "message-symbol", "Message description with detail.", ... ), """ raise InvalidMessageError(error_msg) options.setdefault("scope", default_scope) return MessageDefinition(self, msgid, msg, descr, symbol, **options)