Skip to content

Commit 9f6239f

Browse files
committed
Remove the prefix and indentation for ASCII diagnostic error context
This makes it easier to read, when there are multiple lines as context.
1 parent afd7973 commit 9f6239f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/pip/_internal/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _string_parts(self) -> Iterator[str]:
125125
# Present the main message, with relevant context indented.
126126
yield f"{self.message}\n"
127127
if self.context is not None:
128-
yield _prefix_with_indent("Relevant context: ", self.context)
128+
yield f"\n{self.context}\n"
129129

130130
# Space out the note/hint messages.
131131
if self.attention_stmt is not None or self.hint_stmt is not None:

tests/unit/test_exceptions.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def test_complete(self) -> None:
7373
7474
Oh no!
7575
It broke. :(
76-
Relevant context: Something went wrong
77-
very wrong.
76+
77+
Something went wrong
78+
very wrong.
7879
7980
Note: You did something wrong, which is what caused this error.
8081
Hint: Do it better next time, by trying harder.
@@ -117,8 +118,9 @@ def test_no_note(self) -> None:
117118
118119
Oh no!
119120
It broke. :(
120-
Relevant context: Something went wrong
121-
very wrong.
121+
122+
Something went wrong
123+
very wrong.
122124
123125
Hint: Do it better next time, by trying harder.
124126
"""
@@ -139,8 +141,9 @@ def test_no_hint(self) -> None:
139141
140142
Oh no!
141143
It broke. :(
142-
Relevant context: Something went wrong
143-
very wrong.
144+
145+
Something went wrong
146+
very wrong.
144147
145148
Note: You did something wrong, which is what caused this error.
146149
"""
@@ -201,8 +204,9 @@ def test_no_hint_no_note(self) -> None:
201204
202205
Oh no!
203206
It broke. :(
204-
Relevant context: Something went wrong
205-
very wrong.
207+
208+
Something went wrong
209+
very wrong.
206210
"""
207211
)
208212

0 commit comments

Comments
 (0)