From 2624afb7959a63fec74ca2167414c6d1ab95ed51 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Fri, 3 Dec 2021 14:28:58 +0000 Subject: [PATCH] Clean up where `Text` is used to wrap diagnostic messages. 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. --- src/pip/_internal/exceptions.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pip/_internal/exceptions.py b/src/pip/_internal/exceptions.py index 04fe90fb297..efb96c5eb36 100644 --- a/src/pip/_internal/exceptions.py +++ b/src/pip/_internal/exceptions.py @@ -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.", ) @@ -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.", )