Skip to content
Merged
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ Release date: TBA

* Allow a `.` as a prefix for Sphinx name resolution.

* Checkers must now keep a 1 to 1 relationship between "msgid" (ie: C1234) and "symbol" (ie : human-readable-symbol)
* In checkers, an old_names can now be used for multiple new messages

Caused by #1164. It means if you do a partial old_names for a message definition an exception will tell you that you
must rename the associated identification.


What's New in Pylint 2.3.0?
===========================
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ class ComparisonChecker(_BasicChecker):
"Python is to use isinstance(x, Y) rather than "
"type(x) == Y, type(x) is Y. Though there are unusual "
"situations where these give different results.",
{"old_names": [("W0154", "unidiomatic-typecheck")]},
{"old_names": [("W0154", "old-unidiomatic-typecheck")]},
),
"R0123": (
"Comparison to literal",
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/base_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def __gt__(self, other):

def __repr__(self):
status = "Checker" if self.enabled else "Disabled checker"
return "{} '{}' responsible for {}".format(
status, self.name, ", ".join(self.msgs.keys())
return "{} '{}' (responsible for '{}')".format(
status, self.name, "', '".join(self.msgs.keys())
)

def __str__(self):
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,8 +1680,8 @@ class SpecialMethodsChecker(BaseChecker):
"iterable (i.e. has no `%s` method)" % NEXT_METHOD,
{
"old_names": [
("W0234", "non-iterator-returned"),
("E0234", "non-iterator-returned"),
("W0234", "old-non-iterator-returned-1"),
("E0234", "old-non-iterator-returned-2"),
]
},
),
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _make_graph(filename, dep_info, sect, gtype):
"Unable to import %s",
"import-error",
"Used when pylint has been unable to import a module.",
{"old_names": [("F0401", "import-error")]},
{"old_names": [("F0401", "old-import-error")]},
),
"E0402": (
"Attempted relative import beyond top-level package",
Expand Down
12 changes: 6 additions & 6 deletions pylint/checkers/python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,22 @@ class Python3Checker(checkers.BaseChecker):
"Python3 will not allow implicit unpacking of "
"exceptions in except clauses. "
"See http://www.python.org/dev/peps/pep-3110/",
{"old_names": [("W0712", "unpacking-in-except")]},
{"old_names": [("W0712", "old-unpacking-in-except")]},
),
"E1604": (
"Use raise ErrorClass(args) instead of raise ErrorClass, args.",
"old-raise-syntax",
"Used when the alternate raise syntax "
"'raise foo, bar' is used "
"instead of 'raise foo(bar)'.",
{"old_names": [("W0121", "old-raise-syntax")]},
{"old_names": [("W0121", "old-old-raise-syntax")]},
),
"E1605": (
"Use of the `` operator",
"backtick",
'Used when the deprecated "``" (backtick) operator is used '
"instead of the str() function.",
{"scope": WarningScope.NODE, "old_names": [("W0333", "backtick")]},
{"scope": WarningScope.NODE, "old_names": [("W0333", "old-backtick")]},
),
"E1609": (
"Import * only allowed at module level",
Expand Down Expand Up @@ -358,14 +358,14 @@ class Python3Checker(checkers.BaseChecker):
"indexing-exception",
"Indexing exceptions will not work on Python 3. Use "
"`exception.args[index]` instead.",
{"old_names": [("W0713", "indexing-exception")]},
{"old_names": [("W0713", "old-indexing-exception")]},
),
"W1625": (
"Raising a string exception",
"raising-string",
"Used when a string exception is raised. This will not "
"work on Python 3.",
{"old_names": [("W0701", "raising-string")]},
{"old_names": [("W0701", "old-raising-string")]},
),
"W1626": (
"reload built-in referenced",
Expand Down Expand Up @@ -1369,7 +1369,7 @@ class Python3TokenChecker(checkers.BaseTokenChecker):
"old-ne-operator",
'Used when the deprecated "<>" operator is used instead '
'of "!=". This is removed in Python 3.',
{"maxversion": (3, 0), "old_names": [("W0331", "old-ne-operator")]},
{"maxversion": (3, 0), "old_names": [("W0331", "old-old-ne-operator")]},
),
"E1608": (
"Use of old octal literal",
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/refactoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ class RefactoringChecker(checkers.BaseTokenChecker):
"Used when a function or a method has too many nested "
"blocks. This makes the code less understandable and "
"maintainable.",
{"old_names": [("R0101", "too-many-nested-blocks")]},
{"old_names": [("R0101", "old-too-many-nested-blocks")]},
),
"R1703": (
"The if statement can be replaced with %s",
"simplifiable-if-statement",
"Used when an if statement can be replaced with 'bool(test)'. ",
{"old_names": [("R0102", "simplifiable-if-statement")]},
{"old_names": [("R0102", "old-simplifiable-if-statement")]},
),
"R1704": (
"Redefining argument with the local name %r",
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _missing_member_hint(owner, attrname, distance_threshold, max_choices):
"assignment-from-none",
"Used when an assignment is done on a function call but the "
"inferred function returns nothing but None.",
{"old_names": [("W1111", "assignment-from-none")]},
{"old_names": [("W1111", "old-assignment-from-none")]},
),
"E1129": (
"Context manager '%s' doesn't implement __enter__ and __exit__.",
Expand Down
4 changes: 2 additions & 2 deletions pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,14 @@ def _has_locals_call_after_node(stmt, scope):
"left side has %d label(s), right side has %d value(s)",
"unbalanced-tuple-unpacking",
"Used when there is an unbalanced tuple unpacking in assignment",
{"old_names": [("E0632", "unbalanced-tuple-unpacking")]},
{"old_names": [("E0632", "old-unbalanced-tuple-unpacking")]},
),
"E0633": (
"Attempting to unpack a non-sequence%s",
"unpacking-non-sequence",
"Used when something which is not "
"a sequence is used in an unpack assignment",
{"old_names": [("W0633", "unpacking-non-sequence")]},
{"old_names": [("W0633", "old-unpacking-non-sequence")]},
),
"W0640": (
"Cell variable %s defined in loop",
Expand Down
8 changes: 4 additions & 4 deletions pylint/extensions/docparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DocstringParameterChecker(BaseChecker):
"Missing return documentation",
"missing-return-doc",
"Please add documentation about what this method returns.",
{"old_names": [("W9007", "missing-returns-doc")]},
{"old_names": [("W9007", "old-missing-returns-doc")]},
),
"W9012": (
"Missing return type documentation",
Expand All @@ -91,7 +91,7 @@ class DocstringParameterChecker(BaseChecker):
"Missing yield documentation",
"missing-yield-doc",
"Please add documentation about what this generator yields.",
{"old_names": [("W9009", "missing-yields-doc")]},
{"old_names": [("W9009", "old-missing-yields-doc")]},
),
"W9014": (
"Missing yield type documentation",
Expand All @@ -104,13 +104,13 @@ class DocstringParameterChecker(BaseChecker):
'"%s" missing in parameter documentation',
"missing-param-doc",
"Please add parameter declarations for all parameters.",
{"old_names": [("W9003", "missing-param-doc")]},
{"old_names": [("W9003", "old-missing-param-doc")]},
),
"W9016": (
'"%s" missing in parameter type documentation',
"missing-type-doc",
"Please add parameter type declarations for all parameters.",
{"old_names": [("W9004", "missing-type-doc")]},
{"old_names": [("W9004", "old-missing-type-doc")]},
),
"W9017": (
'"%s" differing in parameter documentation',
Expand Down
2 changes: 2 additions & 0 deletions pylint/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
from pylint.message.message_definition import MessageDefinition
from pylint.message.message_definition_store import MessageDefinitionStore
from pylint.message.message_handler_mix_in import MessagesHandlerMixIn
from pylint.message.message_id_store import MessageIdStore

__all__ = [
"Message",
"MessageDefinition",
"MessageDefinitionStore",
"MessagesHandlerMixIn",
"MessageIdStore",
]
18 changes: 13 additions & 5 deletions pylint/message/message_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,26 @@ def __init__(
old_names=None,
):
self.checker = checker
if len(msgid) != 5:
raise InvalidMessageError("Invalid message id %r" % msgid)
if not msgid[0] in MSG_TYPES:
raise InvalidMessageError("Bad message type %s in %r" % (msgid[0], msgid))
self.check_msgid(msgid)
self.msgid = msgid
self.symbol = symbol
self.msg = msg
self.description = description
self.scope = scope
self.minversion = minversion
self.maxversion = maxversion
self.old_names = old_names or []
self.old_names = []
if old_names:
for old_msgid, old_symbol in old_names:
self.check_msgid(old_msgid)
self.old_names.append([old_msgid, old_symbol])

@staticmethod
def check_msgid(msgid: str) -> None:
if len(msgid) != 5:
raise InvalidMessageError("Invalid message id %r" % msgid)
if msgid[0] not in MSG_TYPES:
raise InvalidMessageError("Bad message type %s in %r" % (msgid[0], msgid))

def __repr__(self):
return "MessageDefinition:%s (%s)" % (self.symbol, self.msgid)
Expand Down
Loading