Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
DiagnosticPipError Class Reference
Inheritance diagram for DiagnosticPipError:
Collaboration diagram for DiagnosticPipError:

Public Member Functions

None __init__ (self, *'Literal["error", "warning"]' kind="error", Optional[str] reference=None, Union[str, Text] message, Optional[Union[str, Text]] context, Optional[Union[str, Text]] hint_stmt, Optional[Union[str, Text]] note_stmt=None, Optional[str] link=None)
 
str __repr__ (self)
 
RenderResult __rich_console__ (self, Console console, ConsoleOptions options)
 

Data Fields

 kind
 
 reference
 
 message
 
 context
 
 note_stmt
 
 hint_stmt
 
 link
 

Static Public Attributes

str reference
 

Detailed Description

An error, that presents diagnostic information to the user.

This contains a bunch of logic, to enable pretty presentation of our error
messages. Each error gets a unique reference. Each error can also include
additional context, a hint and/or a note -- which are presented with the
main error message in a consistent style.

This is adapted from the error output styling in `sphinx-theme-builder`.

Definition at line 61 of file exceptions.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
*'Literal["error", "warning"]'   kind = "error",
Optional[str]   reference = None,
Union[str, Text message,
Optional[Union[str, Text]]  context,
Optional[Union[str, Text]]  hint_stmt,
Optional[Union[str, Text]]   note_stmt = None,
Optional[str]   link = None 
)

Reimplemented in InstallationSubprocessError, MissingPyProjectBuildRequires, InvalidPyProjectBuildRequires, MetadataGenerationFailed, and ExternallyManagedEnvironment.

Definition at line 74 of file exceptions.py.

84 ) -> None:
85 # Ensure a proper reference is provided.
86 if reference is None:
87 assert hasattr(self, "reference"), "error reference not provided!"
88 reference = self.reference
89 assert _is_kebab_case(reference), "error reference must be kebab-case!"
90
91 self.kind = kind
92 self.reference = reference
93
94 self.message = message
95 self.context = context
96
97 self.note_stmt = note_stmt
98 self.hint_stmt = hint_stmt
99
100 self.link = link
101
102 super().__init__(f"<{self.__class__.__name__}: {self.reference}>")
103
for i

References pip._internal.exceptions._is_kebab_case(), i, DiagnosticPipError.reference, MissingPyProjectBuildRequires.reference, InvalidPyProjectBuildRequires.reference, InstallationSubprocessError.reference, MetadataGenerationFailed.reference, and ExternallyManagedEnvironment.reference.

Referenced by Protocol.__init_subclass__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ __repr__()

str __repr__ (   self)

Definition at line 104 of file exceptions.py.

104 def __repr__(self) -> str:
105 return (
106 f"<{self.__class__.__name__}("
107 f"reference={self.reference!r}, "
108 f"message={self.message!r}, "
109 f"context={self.context!r}, "
110 f"note_stmt={self.note_stmt!r}, "
111 f"hint_stmt={self.hint_stmt!r}"
112 ")>"
113 )
114

◆ __rich_console__()

RenderResult __rich_console__ (   self,
Console  console,
ConsoleOptions  options 
)

Definition at line 115 of file exceptions.py.

119 ) -> RenderResult:
120 colour = "red" if self.kind == "error" else "yellow"
121
122 yield f"[{colour} bold]{self.kind}[/]: [bold]{self.reference}[/]"
123 yield ""
124
125 if not options.ascii_only:
126 # Present the main message, with relevant context indented.
127 if self.context is not None:
128 yield _prefix_with_indent(
129 self.message,
130 console,
131 prefix=f"[{colour}]×[/] ",
132 indent=f"[{colour}]│[/] ",
133 )
134 yield _prefix_with_indent(
135 self.context,
136 console,
137 prefix=f"[{colour}]╰─>[/] ",
138 indent=f"[{colour}] [/] ",
139 )
140 else:
141 yield _prefix_with_indent(
142 self.message,
143 console,
144 prefix="[red]×[/] ",
145 indent=" ",
146 )
147 else:
148 yield self.message
149 if self.context is not None:
150 yield ""
151 yield self.context
152
153 if self.note_stmt is not None or self.hint_stmt is not None:
154 yield ""
155
156 if self.note_stmt is not None:
157 yield _prefix_with_indent(
158 self.note_stmt,
159 console,
160 prefix="[magenta bold]note[/]: ",
161 indent=" ",
162 )
163 if self.hint_stmt is not None:
164 yield _prefix_with_indent(
165 self.hint_stmt,
166 console,
167 prefix="[cyan bold]hint[/]: ",
168 indent=" ",
169 )
170
171 if self.link is not None:
172 yield ""
173 yield f"Link: {self.link}"
174
175
176#
177# Actual Errors
178#

References pip._internal.exceptions._prefix_with_indent(), DiagnosticPipError.context, Distribution.context, WrappedSocket.context, DiagnosticPipError.hint_stmt, i, DiagnosticPipError.kind, TempDirectory.kind, CacheEntry.link, DiagnosticPipError.link, LinkSource.link(), _FlatDirectorySource.link(), _LocalFileSource.link(), _RemoteFileSource.link(), _IndexDirectorySource.link(), InstallationCandidate.link, RequirementParts.link, InstallRequirement.link, Style.link, Style.link(), DiagnosticPipError.message, BackendInvalid.message, InvalidResponse.message, and DiagnosticPipError.note_stmt.

Here is the call graph for this function:

Field Documentation

◆ context

◆ hint_stmt

hint_stmt

Definition at line 98 of file exceptions.py.

Referenced by DiagnosticPipError.__rich_console__().

◆ kind

kind

Definition at line 91 of file exceptions.py.

Referenced by DiagnosticPipError.__rich_console__().

◆ link

◆ message

message

Definition at line 94 of file exceptions.py.

Referenced by InvalidResponse.__rich__(), and DiagnosticPipError.__rich_console__().

◆ note_stmt

note_stmt

Definition at line 97 of file exceptions.py.

Referenced by DiagnosticPipError.__rich_console__().

◆ reference [1/2]

str reference
static

Definition at line 72 of file exceptions.py.

Referenced by DiagnosticPipError.__init__().

◆ reference [2/2]

reference

Definition at line 92 of file exceptions.py.

Referenced by DiagnosticPipError.__init__().


The documentation for this class was generated from the following file: