Skip to content

Commit d2133b4

Browse files
committed
Replace {attention -> note}_stmt
The new name is a closer match with what is presented to the user.
1 parent 6ca9eb8 commit d2133b4

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

src/pip/_internal/exceptions.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def __init__(
6868
message: Union[str, Text],
6969
context: Optional[Union[str, Text]],
7070
hint_stmt: Optional[Union[str, Text]],
71-
attention_stmt: Optional[Union[str, Text]] = None,
71+
note_stmt: Optional[Union[str, Text]] = None,
7272
link: Optional[str] = None,
7373
) -> None:
7474
# Ensure a proper reference is provided.
@@ -83,7 +83,7 @@ def __init__(
8383
self.message = message
8484
self.context = context
8585

86-
self.attention_stmt = attention_stmt
86+
self.note_stmt = note_stmt
8787
self.hint_stmt = hint_stmt
8888

8989
self.link = link
@@ -96,7 +96,7 @@ def __repr__(self) -> str:
9696
f"reference={self.reference!r}, "
9797
f"message={self.message!r}, "
9898
f"context={self.context!r}, "
99-
f"attention_stmt={self.attention_stmt!r}, "
99+
f"note_stmt={self.note_stmt!r}, "
100100
f"hint_stmt={self.hint_stmt!r}"
101101
")>"
102102
)
@@ -142,12 +142,12 @@ def __rich_console__(
142142
yield ""
143143
yield self.context
144144

145-
if self.attention_stmt is not None or self.hint_stmt is not None:
145+
if self.note_stmt is not None or self.hint_stmt is not None:
146146
yield ""
147147

148-
if self.attention_stmt is not None:
148+
if self.note_stmt is not None:
149149
yield _prefix_with_indent(
150-
self.attention_stmt,
150+
self.note_stmt,
151151
console,
152152
width_offset=6,
153153
prefix="[magenta bold]note[/]: ",
@@ -194,9 +194,7 @@ def __init__(self, *, package: str) -> None:
194194
"This package has an invalid pyproject.toml file.\n"
195195
R"The \[build-system] table is missing the mandatory `requires` key."
196196
),
197-
attention_stmt=(
198-
"This is an issue with the package mentioned above, not pip."
199-
),
197+
note_stmt="This is an issue with the package mentioned above, not pip.",
200198
hint_stmt=Text("See PEP 518 for the detailed specification."),
201199
)
202200

@@ -214,10 +212,8 @@ def __init__(self, *, package: str, reason: str) -> None:
214212
"pyproject.toml.\n"
215213
f"{reason}"
216214
),
215+
note_stmt="This is an issue with the package mentioned above, not pip.",
217216
hint_stmt=Text("See PEP 518 for the detailed specification."),
218-
attention_stmt=(
219-
"This is an issue with the package mentioned above, not pip."
220-
),
221217
)
222218

223219

tests/unit/test_exceptions.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_complete(self) -> None:
7676
reference="test-diagnostic",
7777
message="Oh no!\nIt broke. :(",
7878
context="Something went wrong\nvery wrong.",
79-
attention_stmt="You did something wrong, which is what caused this error.",
79+
note_stmt="You did something wrong, which is what caused this error.",
8080
hint_stmt="Do it better next time, by trying harder.",
8181
)
8282

@@ -100,7 +100,7 @@ def test_complete_color(self) -> None:
100100
reference="test-diagnostic",
101101
message="Oh no!\nIt broke.",
102102
context="Something went wrong\nvery wrong.",
103-
attention_stmt="You did something wrong.",
103+
note_stmt="You did something wrong.",
104104
hint_stmt="Do it better next time, by trying harder.",
105105
)
106106

@@ -127,7 +127,7 @@ def test_no_context(self) -> None:
127127
reference="test-diagnostic",
128128
message="Oh no!\nIt broke. :(",
129129
context=None,
130-
attention_stmt="You did something wrong, which is what caused this error.",
130+
note_stmt="You did something wrong, which is what caused this error.",
131131
hint_stmt="Do it better next time, by trying harder.",
132132
)
133133

@@ -148,7 +148,7 @@ def test_no_note(self) -> None:
148148
reference="test-diagnostic",
149149
message="Oh no!\nIt broke. :(",
150150
context="Something went wrong\nvery wrong.",
151-
attention_stmt=None,
151+
note_stmt=None,
152152
hint_stmt="Do it better next time, by trying harder.",
153153
)
154154

@@ -171,7 +171,7 @@ def test_no_hint(self) -> None:
171171
reference="test-diagnostic",
172172
message="Oh no!\nIt broke. :(",
173173
context="Something went wrong\nvery wrong.",
174-
attention_stmt="You did something wrong, which is what caused this error.",
174+
note_stmt="You did something wrong, which is what caused this error.",
175175
hint_stmt=None,
176176
)
177177

@@ -194,7 +194,7 @@ def test_no_context_no_hint(self) -> None:
194194
reference="test-diagnostic",
195195
message="Oh no!\nIt broke. :(",
196196
context=None,
197-
attention_stmt="You did something wrong, which is what caused this error.",
197+
note_stmt="You did something wrong, which is what caused this error.",
198198
hint_stmt=None,
199199
)
200200

@@ -214,7 +214,7 @@ def test_no_context_no_note(self) -> None:
214214
reference="test-diagnostic",
215215
message="Oh no!\nIt broke. :(",
216216
context=None,
217-
attention_stmt=None,
217+
note_stmt=None,
218218
hint_stmt="Do it better next time, by trying harder.",
219219
)
220220

@@ -234,7 +234,7 @@ def test_no_hint_no_note(self) -> None:
234234
reference="test-diagnostic",
235235
message="Oh no!\nIt broke. :(",
236236
context="Something went wrong\nvery wrong.",
237-
attention_stmt=None,
237+
note_stmt=None,
238238
hint_stmt=None,
239239
)
240240

@@ -256,7 +256,7 @@ def test_no_hint_no_note_no_context(self) -> None:
256256
message="Oh no!\nIt broke. :(",
257257
context=None,
258258
hint_stmt=None,
259-
attention_stmt=None,
259+
note_stmt=None,
260260
)
261261

262262
assert rendered_in_ascii(err) == textwrap.dedent(
@@ -286,7 +286,7 @@ def test_complete(self) -> None:
286286
reference="test-diagnostic",
287287
message="Oh no!\nIt broke. :(",
288288
context="Something went wrong\nvery wrong.",
289-
attention_stmt="You did something wrong, which is what caused this error.",
289+
note_stmt="You did something wrong, which is what caused this error.",
290290
hint_stmt="Do it better next time, by trying harder.",
291291
)
292292

@@ -309,7 +309,7 @@ def test_complete_color(self) -> None:
309309
reference="test-diagnostic",
310310
message="Oh no!\nIt broke.",
311311
context="Something went wrong\nvery wrong.",
312-
attention_stmt="You did something wrong.",
312+
note_stmt="You did something wrong.",
313313
hint_stmt="Do it better next time, by trying harder.",
314314
)
315315

@@ -335,7 +335,7 @@ def test_no_context(self) -> None:
335335
reference="test-diagnostic",
336336
message="Oh no!\nIt broke. :(",
337337
context=None,
338-
attention_stmt="You did something wrong, which is what caused this error.",
338+
note_stmt="You did something wrong, which is what caused this error.",
339339
hint_stmt="Do it better next time, by trying harder.",
340340
)
341341

@@ -356,7 +356,7 @@ def test_no_note(self) -> None:
356356
reference="test-diagnostic",
357357
message="Oh no!\nIt broke. :(",
358358
context="Something went wrong\nvery wrong.",
359-
attention_stmt=None,
359+
note_stmt=None,
360360
hint_stmt="Do it better next time, by trying harder.",
361361
)
362362

@@ -378,7 +378,7 @@ def test_no_hint(self) -> None:
378378
reference="test-diagnostic",
379379
message="Oh no!\nIt broke. :(",
380380
context="Something went wrong\nvery wrong.",
381-
attention_stmt="You did something wrong, which is what caused this error.",
381+
note_stmt="You did something wrong, which is what caused this error.",
382382
hint_stmt=None,
383383
)
384384

@@ -400,7 +400,7 @@ def test_no_context_no_hint(self) -> None:
400400
reference="test-diagnostic",
401401
message="Oh no!\nIt broke. :(",
402402
context=None,
403-
attention_stmt="You did something wrong, which is what caused this error.",
403+
note_stmt="You did something wrong, which is what caused this error.",
404404
hint_stmt=None,
405405
)
406406

@@ -420,7 +420,7 @@ def test_no_context_no_note(self) -> None:
420420
reference="test-diagnostic",
421421
message="Oh no!\nIt broke. :(",
422422
context=None,
423-
attention_stmt=None,
423+
note_stmt=None,
424424
hint_stmt="Do it better next time, by trying harder.",
425425
)
426426

@@ -440,7 +440,7 @@ def test_no_hint_no_note(self) -> None:
440440
reference="test-diagnostic",
441441
message="Oh no!\nIt broke. :(",
442442
context="Something went wrong\nvery wrong.",
443-
attention_stmt=None,
443+
note_stmt=None,
444444
hint_stmt=None,
445445
)
446446

@@ -461,7 +461,7 @@ def test_no_hint_no_note_no_context(self) -> None:
461461
message="Oh no!\nIt broke. :(",
462462
context=None,
463463
hint_stmt=None,
464-
attention_stmt=None,
464+
note_stmt=None,
465465
)
466466

467467
assert rendered(err) == textwrap.dedent(

0 commit comments

Comments
 (0)