Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions pylint/config/_breaking_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
from typing import NamedTuple


class Intention(enum.Enum):
KEEP = "Keep the same behavior"
USE_DEFAULT = "Use the new default behavior"
# This could/should always be automated
FIX_CONF = "Fix the configuration to become consistent again"


class BreakingChange(enum.Enum):
MESSAGE_MADE_DISABLED_BY_DEFAULT = "{symbol} ({msgid}) was disabled by default"
MESSAGE_MADE_ENABLED_BY_DEFAULT = "{symbol} ({msgid}) was enabled by default"
Expand Down Expand Up @@ -56,13 +63,14 @@ class Solution(enum.Enum):
)
REMOVE_OPTION = "Remove {option} from configuration"
REVIEW_OPTION = "Review and adjust or remove {option}: {description}"
DO_NOTHING = "Do nothing"


ConditionsToBeAffected = list[Condition]
# A solution to a breaking change might imply multiple actions
MultipleActionSolution = list[Solution]
# Sometimes there's multiple solutions and the user needs to choose
Solutions = list[MultipleActionSolution]
Solutions = dict[Intention, MultipleActionSolution]
BreakingChangeWithSolution = tuple[
BreakingChange, Information, ConditionsToBeAffected, Solutions
]
Expand Down Expand Up @@ -101,35 +109,53 @@ class Solution(enum.Enum):
BreakingChange.MESSAGE_MOVED_TO_EXTENSION,
NO_SELF_USE,
[Condition.MESSAGE_IS_ENABLED, Condition.EXTENSION_IS_NOT_LOADED],
[[Solution.ADD_EXTENSION], [Solution.DISABLE_MESSAGE_IMPLICITLY]],
{
Intention.KEEP: [Solution.ADD_EXTENSION],
Intention.USE_DEFAULT: [Solution.DISABLE_MESSAGE_IMPLICITLY],
},
),
],
"3.0.0": [
(
BreakingChange.EXTENSION_REMOVED,
COMPARE_TO_ZERO,
[Condition.MESSAGE_IS_NOT_DISABLED, Condition.EXTENSION_IS_LOADED],
[[Solution.REMOVE_EXTENSION, Solution.ENABLE_MESSAGE_EXPLICITLY]],
{
Intention.FIX_CONF: [
Solution.REMOVE_EXTENSION,
Solution.ENABLE_MESSAGE_EXPLICITLY,
],
},
),
(
BreakingChange.EXTENSION_REMOVED,
COMPARE_TO_EMPTY_STRING,
[Condition.MESSAGE_IS_NOT_DISABLED, Condition.EXTENSION_IS_LOADED],
[[Solution.REMOVE_EXTENSION, Solution.ENABLE_MESSAGE_EXPLICITLY]],
{
Intention.FIX_CONF: [
Solution.REMOVE_EXTENSION,
Solution.ENABLE_MESSAGE_EXPLICITLY,
],
},
),
],
"4.0.0": [
(
BreakingChange.OPTION_REMOVED,
SUGGESTION_MODE_REMOVED,
[Condition.OPTION_IS_PRESENT],
[[Solution.REMOVE_OPTION]],
{
Intention.FIX_CONF: [Solution.REMOVE_OPTION],
},
),
(
BreakingChange.OPTION_BEHAVIOR_CHANGED,
INVALID_NAME_CONST_BEHAVIOR,
[],
[[Solution.REVIEW_OPTION]],
{
Intention.KEEP: [Solution.REVIEW_OPTION],
Intention.USE_DEFAULT: [Solution.DO_NOTHING],
},
),
],
}