Skip to content

Commit 11a2d02

Browse files
[refactor] Better typing for Information
1 parent d93c2fb commit 11a2d02

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pylint/config/_breaking_changes.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ class Condition(enum.Enum):
4141
OPTION_IS_NOT_PRESENT = "{option} is not present in configuration"
4242

4343

44-
class Information(NamedTuple):
45-
msgid_or_symbol: str | None = None
44+
class MessageInformation(NamedTuple):
45+
msgid_or_symbol: str
4646
extension: str | None = None
47-
option: list[str] | str | None = None
47+
48+
49+
class OptionInformation(NamedTuple):
50+
option: list[str] | str
4851
description: str | None = None
4952
new_value: str | None = None
5053

@@ -75,18 +78,19 @@ class Solution(enum.Enum):
7578
MultipleActionSolution = list[Solution]
7679
# Sometimes there's multiple solutions and the user needs to choose
7780
Solutions = dict[Intention, MultipleActionSolution]
81+
Information = MessageInformation | OptionInformation
7882
BreakingChangeWithSolution = tuple[
7983
BreakingChange, Information, ConditionsToBeAffected, Solutions
8084
]
8185

82-
NO_SELF_USE = Information(
86+
NO_SELF_USE = MessageInformation(
8387
msgid_or_symbol="no-self-use", extension="pylint.extensions.no_self_use"
8488
)
8589
CONFIGURATION_BREAKING_CHANGES: dict[str, list[BreakingChangeWithSolution]] = {
8690
"2.7.3": [
8791
(
8892
BreakingChange.OPTION_RENAMED,
89-
Information(
93+
OptionInformation(
9094
option="extension-pkg-whitelist",
9195
new_value="extension-pkg-allow-list",
9296
),
@@ -108,7 +112,7 @@ class Solution(enum.Enum):
108112
"3.0.0": [
109113
(
110114
BreakingChange.EXTENSION_REMOVED,
111-
Information(
115+
MessageInformation(
112116
msgid_or_symbol="compare-to-zero",
113117
extension="pylint.extensions.comparetozero",
114118
),
@@ -122,7 +126,7 @@ class Solution(enum.Enum):
122126
),
123127
(
124128
BreakingChange.EXTENSION_REMOVED,
125-
Information(
129+
MessageInformation(
126130
msgid_or_symbol="compare-to-empty-string",
127131
extension="pylint.extensions.emptystring",
128132
),
@@ -138,7 +142,7 @@ class Solution(enum.Enum):
138142
"4.0.0": [
139143
(
140144
BreakingChange.OPTION_REMOVED,
141-
Information(
145+
OptionInformation(
142146
option="suggestion-mode",
143147
description="This option is no longer used and should be removed",
144148
),
@@ -149,7 +153,7 @@ class Solution(enum.Enum):
149153
),
150154
(
151155
BreakingChange.OPTION_BEHAVIOR_CHANGED,
152-
Information(
156+
OptionInformation(
153157
option=["const-rgx", "const-naming-style"],
154158
description="""\
155159
In 'invalid-name', module-level constants that are reassigned are now treated

0 commit comments

Comments
 (0)