Skip to content

Commit a85bf0c

Browse files
[breaking changes] Add intention behind a possible fix (#10618)
Refs #5462
1 parent 67a0c17 commit a85bf0c

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

pylint/config/_breaking_changes.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
from typing import NamedTuple
1111

1212

13+
class Intention(enum.Enum):
14+
KEEP = "Keep the same behavior"
15+
USE_DEFAULT = "Use the new default behavior"
16+
# This could/should always be automated
17+
FIX_CONF = "Fix the configuration to become consistent again"
18+
19+
1320
class BreakingChange(enum.Enum):
1421
MESSAGE_MADE_DISABLED_BY_DEFAULT = "{symbol} ({msgid}) was disabled by default"
1522
MESSAGE_MADE_ENABLED_BY_DEFAULT = "{symbol} ({msgid}) was enabled by default"
@@ -56,13 +63,14 @@ class Solution(enum.Enum):
5663
)
5764
REMOVE_OPTION = "Remove {option} from configuration"
5865
REVIEW_OPTION = "Review and adjust or remove {option}: {description}"
66+
DO_NOTHING = "Do nothing"
5967

6068

6169
ConditionsToBeAffected = list[Condition]
6270
# A solution to a breaking change might imply multiple actions
6371
MultipleActionSolution = list[Solution]
6472
# Sometimes there's multiple solutions and the user needs to choose
65-
Solutions = list[MultipleActionSolution]
73+
Solutions = dict[Intention, MultipleActionSolution]
6674
BreakingChangeWithSolution = tuple[
6775
BreakingChange, Information, ConditionsToBeAffected, Solutions
6876
]
@@ -101,35 +109,53 @@ class Solution(enum.Enum):
101109
BreakingChange.MESSAGE_MOVED_TO_EXTENSION,
102110
NO_SELF_USE,
103111
[Condition.MESSAGE_IS_ENABLED, Condition.EXTENSION_IS_NOT_LOADED],
104-
[[Solution.ADD_EXTENSION], [Solution.DISABLE_MESSAGE_IMPLICITLY]],
112+
{
113+
Intention.KEEP: [Solution.ADD_EXTENSION],
114+
Intention.USE_DEFAULT: [Solution.DISABLE_MESSAGE_IMPLICITLY],
115+
},
105116
),
106117
],
107118
"3.0.0": [
108119
(
109120
BreakingChange.EXTENSION_REMOVED,
110121
COMPARE_TO_ZERO,
111122
[Condition.MESSAGE_IS_NOT_DISABLED, Condition.EXTENSION_IS_LOADED],
112-
[[Solution.REMOVE_EXTENSION, Solution.ENABLE_MESSAGE_EXPLICITLY]],
123+
{
124+
Intention.FIX_CONF: [
125+
Solution.REMOVE_EXTENSION,
126+
Solution.ENABLE_MESSAGE_EXPLICITLY,
127+
],
128+
},
113129
),
114130
(
115131
BreakingChange.EXTENSION_REMOVED,
116132
COMPARE_TO_EMPTY_STRING,
117133
[Condition.MESSAGE_IS_NOT_DISABLED, Condition.EXTENSION_IS_LOADED],
118-
[[Solution.REMOVE_EXTENSION, Solution.ENABLE_MESSAGE_EXPLICITLY]],
134+
{
135+
Intention.FIX_CONF: [
136+
Solution.REMOVE_EXTENSION,
137+
Solution.ENABLE_MESSAGE_EXPLICITLY,
138+
],
139+
},
119140
),
120141
],
121142
"4.0.0": [
122143
(
123144
BreakingChange.OPTION_REMOVED,
124145
SUGGESTION_MODE_REMOVED,
125146
[Condition.OPTION_IS_PRESENT],
126-
[[Solution.REMOVE_OPTION]],
147+
{
148+
Intention.FIX_CONF: [Solution.REMOVE_OPTION],
149+
},
127150
),
128151
(
129152
BreakingChange.OPTION_BEHAVIOR_CHANGED,
130153
INVALID_NAME_CONST_BEHAVIOR,
131154
[],
132-
[[Solution.REVIEW_OPTION]],
155+
{
156+
Intention.KEEP: [Solution.REVIEW_OPTION],
157+
Intention.USE_DEFAULT: [Solution.DO_NOTHING],
158+
},
133159
),
134160
],
135161
}

0 commit comments

Comments
 (0)