Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve presentation of diagnostic errors using rich #10703

Merged
merged 10 commits into from
Dec 14, 2021
Prev Previous commit
Next Next commit
Escape the package name, allowing rich to stylize URLs and links
  • Loading branch information
pradyunsg committed Dec 12, 2021
commit 6b31f83187edf1c566269bc276309091fe8a6509
5 changes: 3 additions & 2 deletions src/pip/_internal/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from pip._vendor.requests.models import Request, Response
from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
from pip._vendor.rich.markup import escape
from pip._vendor.rich.text import Text

if TYPE_CHECKING:
Expand Down Expand Up @@ -182,7 +183,7 @@ class MissingPyProjectBuildRequires(DiagnosticPipError):

def __init__(self, *, package: str) -> None:
super().__init__(
message=Text(f"Can not process {package}"),
message=f"Can not process {escape(package)}",
context=Text(
"This package has an invalid pyproject.toml file.\n"
"The [build-system] table is missing the mandatory `requires` key."
Expand All @@ -199,7 +200,7 @@ class InvalidPyProjectBuildRequires(DiagnosticPipError):

def __init__(self, *, package: str, reason: str) -> None:
super().__init__(
message=Text(f"Can not process {package}"),
message=f"Can not process {escape(package)}",
context=Text(
"This package has an invalid `build-system.requires` key in "
f"pyproject.toml.\n{reason}"
Expand Down