Skip to content

Commit

Permalink
Replace {attention -> note}_stmt
Browse files Browse the repository at this point in the history
The new name is a closer match with what is presented to the user.
  • Loading branch information
pradyunsg committed Dec 3, 2021
1 parent 9664158 commit 6443411
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
20 changes: 8 additions & 12 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(
message: Union[str, Text],
context: Optional[Union[str, Text]],
hint_stmt: Optional[Union[str, Text]],
attention_stmt: Optional[Union[str, Text]] = None,
note_stmt: Optional[Union[str, Text]] = None,
link: Optional[str] = None,
) -> None:
# Ensure a proper reference is provided.
Expand All @@ -83,7 +83,7 @@ def __init__(
self.message = message
self.context = context

self.attention_stmt = attention_stmt
self.note_stmt = note_stmt
self.hint_stmt = hint_stmt

self.link = link
Expand All @@ -96,7 +96,7 @@ def __repr__(self) -> str:
f"reference={self.reference!r}, "
f"message={self.message!r}, "
f"context={self.context!r}, "
f"attention_stmt={self.attention_stmt!r}, "
f"note_stmt={self.note_stmt!r}, "
f"hint_stmt={self.hint_stmt!r}"
")>"
)
Expand Down Expand Up @@ -142,12 +142,12 @@ def __rich_console__(
yield ""
yield self.context

if self.attention_stmt is not None or self.hint_stmt is not None:
if self.note_stmt is not None or self.hint_stmt is not None:
yield ""

if self.attention_stmt is not None:
if self.note_stmt is not None:
yield _prefix_with_indent(
self.attention_stmt,
self.note_stmt,
console,
width_offset=6,
prefix="[magenta bold]note[/]: ",
Expand Down Expand Up @@ -194,9 +194,7 @@ def __init__(self, *, package: str) -> None:
"This package has an invalid pyproject.toml file.\n"
R"The \[build-system] table is missing the mandatory `requires` key."
),
attention_stmt=(
"This is an issue with the package mentioned above, not pip."
),
note_stmt="This is an issue with the package mentioned above, not pip.",
hint_stmt=Text("See PEP 518 for the detailed specification."),
)

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


Expand Down
36 changes: 18 additions & 18 deletions tests/unit/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_complete(self) -> None:
reference="test-diagnostic",
message="Oh no!\nIt broke. :(",
context="Something went wrong\nvery wrong.",
attention_stmt="You did something wrong, which is what caused this error.",
note_stmt="You did something wrong, which is what caused this error.",
hint_stmt="Do it better next time, by trying harder.",
)

Expand All @@ -100,7 +100,7 @@ def test_complete_color(self) -> None:
reference="test-diagnostic",
message="Oh no!\nIt broke.",
context="Something went wrong\nvery wrong.",
attention_stmt="You did something wrong, which is what caused this error.",
note_stmt="You did something wrong, which is what caused this error.",
hint_stmt="Do it better next time, by trying harder.",
)

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

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

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

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

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

Expand All @@ -234,7 +234,7 @@ def test_no_hint_no_note(self) -> None:
reference="test-diagnostic",
message="Oh no!\nIt broke. :(",
context="Something went wrong\nvery wrong.",
attention_stmt=None,
note_stmt=None,
hint_stmt=None,
)

Expand All @@ -256,7 +256,7 @@ def test_no_hint_no_note_no_context(self) -> None:
message="Oh no!\nIt broke. :(",
context=None,
hint_stmt=None,
attention_stmt=None,
note_stmt=None,
)

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

Expand All @@ -309,7 +309,7 @@ def test_complete_color(self) -> None:
reference="test-diagnostic",
message="Oh no!\nIt broke.",
context="Something went wrong\nvery wrong.",
attention_stmt="You did something wrong, which is what caused this error.",
note_stmt="You did something wrong, which is what caused this error.",
hint_stmt="Do it better next time, by trying harder.",
)

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

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

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

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

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

Expand All @@ -440,7 +440,7 @@ def test_no_hint_no_note(self) -> None:
reference="test-diagnostic",
message="Oh no!\nIt broke. :(",
context="Something went wrong\nvery wrong.",
attention_stmt=None,
note_stmt=None,
hint_stmt=None,
)

Expand All @@ -461,7 +461,7 @@ def test_no_hint_no_note_no_context(self) -> None:
message="Oh no!\nIt broke. :(",
context=None,
hint_stmt=None,
attention_stmt=None,
note_stmt=None,
)

assert rendered(err) == textwrap.dedent(
Expand Down

0 comments on commit 6443411

Please sign in to comment.