Skip to content

Commit 06b2b19

Browse files
Take review into account
1 parent 1fe4b8a commit 06b2b19

File tree

6 files changed

+132
-107
lines changed

6 files changed

+132
-107
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ Release date: TBA
1515

1616
Closes #352
1717

18+
* ``using-f-string-in-unsupported-version`` and ``using-final-decorator-in-unsupported-version`` msgids
19+
were renamed from ``W1601`` and ``W1602`` to ``W2601`` and ``W2602``. Disabling using these msgids will break.
20+
This is done in order to restore consistency with the already existing msgids for ``apply-builtin`` and
21+
``basestring-builtin`` from the now deleted python 3K+ checker. There is now a check that we're not using
22+
existing msgids or symbols from deleted checkers.
23+
24+
Closes #5729
25+
26+
1827
* Add ``modified-iterating-list``, ``modified-iterating-dict`` and ``modified-iterating-set``,
1928
emitted when items are added to or removed from respectively a list, dictionary or
2029
set being iterated through.

doc/whatsnew/2.13.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ Other Changes
9898

9999
Closes #352
100100

101+
* ``using-f-string-in-unsupported-version`` and ``using-final-decorator-in-unsupported-version`` msgids
102+
were renamed from ``W1601`` and ``W1602`` to ``W2601`` and ``W2602``. Disables using these msgids will break.
103+
This is done in order to restore consistency with the already existing msgids for ``apply-builtin`` and
104+
``basestring-builtin`` from the now deleted python 3K+ checker. There is now a check that we're not using
105+
existing msgids or symbols from deleted checkers.
106+
107+
Closes #5729
108+
101109
* Fix false-negative for ``assignment-from-none`` checker with list.sort() method.
102110

103111
Closes #5722

pylint/checkers/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@
3737
13: string_format
3838
14: string_constant
3939
15: stdlib
40-
16: python3
40+
16: python3 (This one was deleted but needs to be reserved for consistency with old messages)
4141
17: refactoring
4242
.
4343
.
4444
.
4545
24: non-ascii-names
4646
25: unicode
47-
26-50: not yet used: reserved for future internal checkers.
47+
26: unsupported_version
48+
27-50: not yet used: reserved for future internal checkers.
4849
This file is not updated. Use
4950
script/get_unused_message_id_category.py
5051
to get the next free checker id.

pylint/constants.py

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
33
import platform
44
import sys
5-
from typing import Dict
5+
from typing import Dict, List, NamedTuple, Tuple
66

77
import astroid
88
import platformdirs
@@ -72,3 +72,107 @@ class WarningScope:
7272
"class_const": "class constant",
7373
"inlinevar": "inline iteration",
7474
}
75+
76+
77+
class DeletedMessage(NamedTuple):
78+
msgid: str
79+
symbol: str
80+
old_names: List[Tuple[str, str]] = []
81+
82+
83+
DELETED_MSGID_PREFIXES = [
84+
16, # the PY3K+ checker, see https://github.com/PyCQA/pylint/pull/4942
85+
]
86+
87+
DELETED_MESSAGES = [
88+
# Everything until the next comment is from the
89+
# PY3K+ checker, see https://github.com/PyCQA/pylint/pull/4942
90+
DeletedMessage("W1601", "apply-builtin"),
91+
DeletedMessage("E1601", "print-statement"),
92+
DeletedMessage("E1602", "parameter-unpacking"),
93+
DeletedMessage(
94+
"E1603", "unpacking-in-except", [("W0712", "old-unpacking-in-except")]
95+
),
96+
DeletedMessage("E1604", "old-raise-syntax", [("W0121", "old-old-raise-syntax")]),
97+
DeletedMessage("E1605", "backtick", [("W0333", "old-backtick")]),
98+
DeletedMessage("E1609", "import-star-module-level"),
99+
DeletedMessage("W1601", "apply-builtin"),
100+
DeletedMessage("W1602", "basestring-builtin"),
101+
DeletedMessage("W1603", "buffer-builtin"),
102+
DeletedMessage("W1604", "cmp-builtin"),
103+
DeletedMessage("W1605", "coerce-builtin"),
104+
DeletedMessage("W1606", "execfile-builtin"),
105+
DeletedMessage("W1607", "file-builtin"),
106+
DeletedMessage("W1608", "long-builtin"),
107+
DeletedMessage("W1609", "raw_input-builtin"),
108+
DeletedMessage("W1610", "reduce-builtin"),
109+
DeletedMessage("W1611", "standarderror-builtin"),
110+
DeletedMessage("W1612", "unicode-builtin"),
111+
DeletedMessage("W1613", "xrange-builtin"),
112+
DeletedMessage("W1614", "coerce-method"),
113+
DeletedMessage("W1615", "delslice-method"),
114+
DeletedMessage("W1616", "getslice-method"),
115+
DeletedMessage("W1617", "setslice-method"),
116+
DeletedMessage("W1618", "no-absolute-import"),
117+
DeletedMessage("W1619", "old-division"),
118+
DeletedMessage("W1620", "dict-iter-method"),
119+
DeletedMessage("W1621", "dict-view-method"),
120+
DeletedMessage("W1622", "next-method-called"),
121+
DeletedMessage("W1623", "metaclass-assignment"),
122+
DeletedMessage(
123+
"W1624", "indexing-exception", [("W0713", "old-indexing-exception")]
124+
),
125+
DeletedMessage("W1625", "raising-string", [("W0701", "old-raising-string")]),
126+
DeletedMessage("W1626", "reload-builtin"),
127+
DeletedMessage("W1627", "oct-method"),
128+
DeletedMessage("W1628", "hex-method"),
129+
DeletedMessage("W1629", "nonzero-method"),
130+
DeletedMessage("W1630", "cmp-method"),
131+
DeletedMessage("W1632", "input-builtin"),
132+
DeletedMessage("W1633", "round-builtin"),
133+
DeletedMessage("W1634", "intern-builtin"),
134+
DeletedMessage("W1635", "unichr-builtin"),
135+
DeletedMessage(
136+
"W1636", "map-builtin-not-iterating", [("W1631", "implicit-map-evaluation")]
137+
),
138+
DeletedMessage("W1637", "zip-builtin-not-iterating"),
139+
DeletedMessage("W1638", "range-builtin-not-iterating"),
140+
DeletedMessage("W1639", "filter-builtin-not-iterating"),
141+
DeletedMessage("W1640", "using-cmp-argument"),
142+
DeletedMessage("W1641", "eq-without-hash"),
143+
DeletedMessage("W1642", "div-method"),
144+
DeletedMessage("W1643", "idiv-method"),
145+
DeletedMessage("W1644", "rdiv-method"),
146+
DeletedMessage("W1645", "exception-message-attribute"),
147+
DeletedMessage("W1646", "invalid-str-codec"),
148+
DeletedMessage("W1647", "sys-max-int"),
149+
DeletedMessage("W1648", "bad-python3-import"),
150+
DeletedMessage("W1649", "deprecated-string-function"),
151+
DeletedMessage("W1650", "deprecated-str-translate-call"),
152+
DeletedMessage("W1651", "deprecated-itertools-function"),
153+
DeletedMessage("W1652", "deprecated-types-field"),
154+
DeletedMessage("W1653", "next-method-defined"),
155+
DeletedMessage("W1654", "dict-items-not-iterating"),
156+
DeletedMessage("W1655", "dict-keys-not-iterating"),
157+
DeletedMessage("W1656", "dict-values-not-iterating"),
158+
DeletedMessage("W1657", "deprecated-operator-function"),
159+
DeletedMessage("W1658", "deprecated-urllib-function"),
160+
DeletedMessage("W1659", "xreadlines-attribute"),
161+
DeletedMessage("W1660", "deprecated-sys-function"),
162+
DeletedMessage("W1661", "exception-escape"),
163+
DeletedMessage("W1662", "comprehension-escape"),
164+
# https://github.com/PyCQA/pylint/pull/3578
165+
DeletedMessage("W0312", "mixed-indentation"),
166+
# https://github.com/PyCQA/pylint/pull/3577
167+
DeletedMessage(
168+
"C0326",
169+
"bad-whitespace",
170+
[
171+
("C0323", "no-space-after-operator"),
172+
("C0324", "no-space-after-comma"),
173+
("C0322", "no-space-before-operator"),
174+
],
175+
),
176+
# https://github.com/PyCQA/pylint/pull/3571
177+
DeletedMessage("C0330", "bad-continuation"),
178+
]

script/get_unused_message_id_category.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import List
66

77
from pylint.checkers import initialize as initialize_checkers
8+
from pylint.constants import DELETED_MSGID_PREFIXES
89
from pylint.extensions import initialize as initialize_extensions
910
from pylint.lint.pylinter import PyLinter
1011

@@ -18,8 +19,8 @@ def register_all_checkers_and_plugins(linter: "PyLinter") -> None:
1819

1920
def get_next_code_category(message_ids: List[str]) -> int:
2021
categories = sorted({int(i[:2]) for i in message_ids})
21-
# 16 was the deleted python 3k+ checker.
22-
categories.append(16)
22+
# We add the prefixes for deleted checkers
23+
categories += DELETED_MSGID_PREFIXES
2324
for i in categories:
2425
if i + 1 not in categories:
2526
return i + 1
Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,20 @@
11
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
3-
from typing import TYPE_CHECKING, List, NamedTuple, Tuple
3+
from typing import TYPE_CHECKING
4+
5+
from pylint.constants import DELETED_MESSAGES
46

57
if TYPE_CHECKING:
68
from pylint.lint import PyLinter
79

810

9-
class DeletedMessage(NamedTuple):
10-
msgid: str
11-
symbol: str
12-
old_names: List[Tuple[str, str]] = []
13-
14-
15-
OLD_MSGID_SYMBOL_PAIR = [
16-
# Everything until the next comment is from the
17-
# PY3K+ checker, see https://github.com/PyCQA/pylint/pull/4942
18-
DeletedMessage("W1601", "apply-builtin"),
19-
DeletedMessage("E1601", "print-statement"),
20-
DeletedMessage("E1602", "parameter-unpacking"),
21-
DeletedMessage(
22-
"E1603", "unpacking-in-except", [("W0712", "old-unpacking-in-except")]
23-
),
24-
DeletedMessage("E1604", "old-raise-syntax", [("W0121", "old-old-raise-syntax")]),
25-
DeletedMessage("E1605", "backtick", [("W0333", "old-backtick")]),
26-
DeletedMessage("E1609", "import-star-module-level"),
27-
DeletedMessage("W1601", "apply-builtin"),
28-
DeletedMessage("W1602", "basestring-builtin"),
29-
DeletedMessage("W1603", "buffer-builtin"),
30-
DeletedMessage("W1604", "cmp-builtin"),
31-
DeletedMessage("W1605", "coerce-builtin"),
32-
DeletedMessage("W1606", "execfile-builtin"),
33-
DeletedMessage("W1607", "file-builtin"),
34-
DeletedMessage("W1608", "long-builtin"),
35-
DeletedMessage("W1609", "raw_input-builtin"),
36-
DeletedMessage("W1610", "reduce-builtin"),
37-
DeletedMessage("W1611", "standarderror-builtin"),
38-
DeletedMessage("W1612", "unicode-builtin"),
39-
DeletedMessage("W1613", "xrange-builtin"),
40-
DeletedMessage("W1614", "coerce-method"),
41-
DeletedMessage("W1615", "delslice-method"),
42-
DeletedMessage("W1616", "getslice-method"),
43-
DeletedMessage("W1617", "setslice-method"),
44-
DeletedMessage("W1618", "no-absolute-import"),
45-
DeletedMessage("W1619", "old-division"),
46-
DeletedMessage("W1620", "dict-iter-method"),
47-
DeletedMessage("W1621", "dict-view-method"),
48-
DeletedMessage("W1622", "next-method-called"),
49-
DeletedMessage("W1623", "metaclass-assignment"),
50-
DeletedMessage(
51-
"W1624", "indexing-exception", [("W0713", "old-indexing-exception")]
52-
),
53-
DeletedMessage("W1625", "raising-string", [("W0701", "old-raising-string")]),
54-
DeletedMessage("W1626", "reload-builtin"),
55-
DeletedMessage("W1627", "oct-method"),
56-
DeletedMessage("W1628", "hex-method"),
57-
DeletedMessage("W1629", "nonzero-method"),
58-
DeletedMessage("W1630", "cmp-method"),
59-
DeletedMessage("W1632", "input-builtin"),
60-
DeletedMessage("W1633", "round-builtin"),
61-
DeletedMessage("W1634", "intern-builtin"),
62-
DeletedMessage("W1635", "unichr-builtin"),
63-
DeletedMessage(
64-
"W1636", "map-builtin-not-iterating", [("W1631", "implicit-map-evaluation")]
65-
),
66-
DeletedMessage("W1637", "zip-builtin-not-iterating"),
67-
DeletedMessage("W1638", "range-builtin-not-iterating"),
68-
DeletedMessage("W1639", "filter-builtin-not-iterating"),
69-
DeletedMessage("W1640", "using-cmp-argument"),
70-
DeletedMessage("W1641", "eq-without-hash"),
71-
DeletedMessage("W1642", "div-method"),
72-
DeletedMessage("W1643", "idiv-method"),
73-
DeletedMessage("W1644", "rdiv-method"),
74-
DeletedMessage("W1645", "exception-message-attribute"),
75-
DeletedMessage("W1646", "invalid-str-codec"),
76-
DeletedMessage("W1647", "sys-max-int"),
77-
DeletedMessage("W1648", "bad-python3-import"),
78-
DeletedMessage("W1649", "deprecated-string-function"),
79-
DeletedMessage("W1650", "deprecated-str-translate-call"),
80-
DeletedMessage("W1651", "deprecated-itertools-function"),
81-
DeletedMessage("W1652", "deprecated-types-field"),
82-
DeletedMessage("W1653", "next-method-defined"),
83-
DeletedMessage("W1654", "dict-items-not-iterating"),
84-
DeletedMessage("W1655", "dict-keys-not-iterating"),
85-
DeletedMessage("W1656", "dict-values-not-iterating"),
86-
DeletedMessage("W1657", "deprecated-operator-function"),
87-
DeletedMessage("W1658", "deprecated-urllib-function"),
88-
DeletedMessage("W1659", "xreadlines-attribute"),
89-
DeletedMessage("W1660", "deprecated-sys-function"),
90-
DeletedMessage("W1661", "exception-escape"),
91-
DeletedMessage("W1662", "comprehension-escape"),
92-
# https://github.com/PyCQA/pylint/pull/3578
93-
DeletedMessage("W0312", "mixed-indentation"),
94-
# https://github.com/PyCQA/pylint/pull/3577
95-
DeletedMessage(
96-
"C0326",
97-
"bad-whitespace",
98-
[
99-
("C0323", "no-space-after-operator"),
100-
("C0324", "no-space-after-comma"),
101-
("C0322", "no-space-before-operator"),
102-
],
103-
),
104-
# https://github.com/PyCQA/pylint/pull/3571
105-
DeletedMessage("C0330", "bad-continuation"),
106-
]
107-
108-
10911
def test_no_removed_msgid_or_symbol_used(linter: "PyLinter") -> None:
11012
"""Tests that we're not using deleted msgid or symbol.
11113
11214
This would be causing occasional bug, but more than that confusion and inconsistencies
11315
when searching for the msgid online. See https://github.com/PyCQA/pylint/issues/5729
11416
"""
115-
for msgid, symbol, old_names in OLD_MSGID_SYMBOL_PAIR:
17+
for msgid, symbol, old_names in DELETED_MESSAGES:
11618
linter.msgs_store.message_id_store.register_message_definition(
11719
msgid, symbol, old_names
11820
)

0 commit comments

Comments
 (0)