|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | import sys |
3 | | -from typing import Optional, List, Dict, Any |
| 3 | +from typing import Optional, List, Dict |
4 | 4 |
|
5 | 5 |
|
6 | 6 | class TwilioException(Exception): |
@@ -145,47 +145,63 @@ def yellow(words: str) -> str: |
145 | 145 | "\n{red_error} {request_was}\n\n{http_line}\n\n{twilio_returned}\n".format( |
146 | 146 | red_error=red("HTTP Error"), |
147 | 147 | request_was=white("Your request was:"), |
148 | | - http_line=teal("%s %s" % (self.method, self.uri)) if self.uri else teal("(no URI)"), |
| 148 | + http_line=( |
| 149 | + teal("%s %s" % (self.method, self.uri)) |
| 150 | + if self.uri |
| 151 | + else teal("(no URI)") |
| 152 | + ), |
149 | 153 | twilio_returned=white("Twilio returned the following information:"), |
150 | 154 | ) |
151 | 155 | ] |
152 | 156 |
|
153 | 157 | # Title and detail |
154 | | - msg_parts.append("\n{title_label}: {title}\n".format( |
155 | | - title_label=white("Title"), |
156 | | - title=blue(self.title), |
157 | | - )) |
| 158 | + msg_parts.append( |
| 159 | + "\n{title_label}: {title}\n".format( |
| 160 | + title_label=white("Title"), |
| 161 | + title=blue(self.title), |
| 162 | + ) |
| 163 | + ) |
158 | 164 |
|
159 | 165 | if self.detail: |
160 | | - msg_parts.append("{detail_label}: {detail}\n".format( |
161 | | - detail_label=white("Detail"), |
162 | | - detail=blue(self.detail), |
163 | | - )) |
| 166 | + msg_parts.append( |
| 167 | + "{detail_label}: {detail}\n".format( |
| 168 | + detail_label=white("Detail"), |
| 169 | + detail=blue(self.detail), |
| 170 | + ) |
| 171 | + ) |
164 | 172 |
|
165 | 173 | # Code and status |
166 | | - msg_parts.append("{code_label}: {code} | {status_label}: {status}\n".format( |
167 | | - code_label=white("Error Code"), |
168 | | - code=blue(str(self.code)), |
169 | | - status_label=white("Status"), |
170 | | - status=blue(str(self.status)), |
171 | | - )) |
| 174 | + msg_parts.append( |
| 175 | + "{code_label}: {code} | {status_label}: {status}\n".format( |
| 176 | + code_label=white("Error Code"), |
| 177 | + code=blue(str(self.code)), |
| 178 | + status_label=white("Status"), |
| 179 | + status=blue(str(self.status)), |
| 180 | + ) |
| 181 | + ) |
172 | 182 |
|
173 | 183 | # Validation errors if present |
174 | 184 | if self.errors: |
175 | | - msg_parts.append("\n{validation_label}:\n".format( |
176 | | - validation_label=white("Validation Errors"), |
177 | | - )) |
| 185 | + msg_parts.append( |
| 186 | + "\n{validation_label}:\n".format( |
| 187 | + validation_label=white("Validation Errors"), |
| 188 | + ) |
| 189 | + ) |
178 | 190 | for error in self.errors: |
179 | | - msg_parts.append(" {pointer}: {detail}\n".format( |
180 | | - pointer=yellow(error.get("pointer", "(unknown field)")), |
181 | | - detail=error.get("detail", "(no detail)"), |
182 | | - )) |
| 191 | + msg_parts.append( |
| 192 | + " {pointer}: {detail}\n".format( |
| 193 | + pointer=yellow(error.get("pointer", "(unknown field)")), |
| 194 | + detail=error.get("detail", "(no detail)"), |
| 195 | + ) |
| 196 | + ) |
183 | 197 |
|
184 | 198 | # Documentation link |
185 | | - msg_parts.append("\n{more_info}\n\n{uri}\n\n".format( |
186 | | - more_info=white("More information may be available here:"), |
187 | | - uri=blue(self.type), |
188 | | - )) |
| 199 | + msg_parts.append( |
| 200 | + "\n{more_info}\n\n{uri}\n\n".format( |
| 201 | + more_info=white("More information may be available here:"), |
| 202 | + uri=blue(self.type), |
| 203 | + ) |
| 204 | + ) |
189 | 205 |
|
190 | 206 | return "".join(msg_parts) |
191 | 207 | else: |
|
0 commit comments