third_party.pylibs.pylint.src/pylint/message/build_message_definition.py
Pierre Sassoulas 1dbbb35d93 Refactor - Avoid intra-packages circular dependencies for constants
Some constants were package internal but were used by multiple
packages. This created circular dependencies. By creating a
file for constants we make sure this does not happen because
we won't import everything important in this file and every
thing else can depend on it.
2019-03-29 09:37:05 +01:00

35 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
import warnings
from pylint.constants import WarningScope
from pylint.interfaces import IRawChecker, ITokenChecker, implements
from pylint.message.message_definition import MessageDefinition
def build_message_def(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)