Skip to content

Commit

Permalink
Clean up where Text is used to wrap diagnostic messages.
Browse files Browse the repository at this point in the history
This is only necessary on messages which may contain `[`, which needs to
be escaped before printing with rich, since rich treats them as output
formats.
  • Loading branch information
pradyunsg committed Dec 3, 2021
1 parent d2133b4 commit e144173
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ class MissingPyProjectBuildRequires(DiagnosticPipError):

def __init__(self, *, package: str) -> None:
super().__init__(
message=f"Can not process {package}",
context=(
message=Text(f"Can not process {package}"),
context=Text(
"This package has an invalid pyproject.toml file.\n"
R"The \[build-system] table is missing the mandatory `requires` key."
"The [build-system] table is missing the mandatory `requires` key."
),
note_stmt="This is an issue with the package mentioned above, not pip.",
hint_stmt=Text("See PEP 518 for the detailed specification."),
hint_stmt="See PEP 518 for the detailed specification.",
)


Expand All @@ -206,14 +206,13 @@ class InvalidPyProjectBuildRequires(DiagnosticPipError):

def __init__(self, *, package: str, reason: str) -> None:
super().__init__(
message=f"Can not process {package}",
message=Text(f"Can not process {package}"),
context=Text(
"This package has an invalid `build-system.requires` key in "
"pyproject.toml.\n"
f"{reason}"
f"pyproject.toml.\n{reason}"
),
note_stmt="This is an issue with the package mentioned above, not pip.",
hint_stmt=Text("See PEP 518 for the detailed specification."),
hint_stmt="See PEP 518 for the detailed specification.",
)


Expand Down

0 comments on commit e144173

Please sign in to comment.