Skip to content

Commit 14ad397

Browse files
committed
Make linter happier.
1 parent 3d6aaff commit 14ad397

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/checkers/rst-yamllint.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,13 @@ def visit_literal_block(self, node: nodes.literal_block) -> None:
196196
}
197197
)
198198
except Exception as exc:
199+
error = str(exc).replace("\n", " / ")
199200
self.__results.append(
200201
{
201202
"path": self.__path,
202203
"line": row_offset + 1,
203204
"col": col_offset + 1,
204-
"message": f"Internal error while linting YAML: exception {type(exc)}: {str(exc).replace("\n", " / ")}; traceback: {traceback.format_exc()!r}",
205+
"message": f"Internal error while linting YAML: exception {type(exc)}: {error}; traceback: {traceback.format_exc()!r}",
205206
}
206207
)
207208

@@ -260,22 +261,24 @@ def main():
260261
publisher.source, publisher.parser, publisher.settings
261262
)
262263
except SystemMessage as exc:
264+
error = str(exc).replace("\n", " / ")
263265
results.append(
264266
{
265267
"path": path,
266268
"line": 0,
267269
"col": 0,
268-
"message": f'Cannot parse document: {str(exc).replace("\n", " / ")}',
270+
"message": f"Cannot parse document: {error}",
269271
}
270272
)
271273
continue
272274
except Exception as exc:
275+
error = str(exc).replace("\n", " / ")
273276
results.append(
274277
{
275278
"path": path,
276279
"line": 0,
277280
"col": 0,
278-
"message": f'Cannot parse document, unexpected error {type(exc)}: {str(exc).replace("\n", " / ")}; traceback: {traceback.format_exc()!r}',
281+
"message": f"Cannot parse document, unexpected error {type(exc)}: {error}; traceback: {traceback.format_exc()!r}",
279282
}
280283
)
281284
continue
@@ -285,12 +288,13 @@ def main():
285288
visitor = YamlLintVisitor(doc, path, results, content, yamllint_config)
286289
doc.walk(visitor)
287290
except Exception as exc:
291+
error = str(exc).replace("\n", " / ")
288292
results.append(
289293
{
290294
"path": path,
291295
"line": 0,
292296
"col": 0,
293-
"message": f'Cannot process document: {type(exc)} {str(exc).replace("\n", " / ")}; traceback: {traceback.format_exc()!r}',
297+
"message": f"Cannot process document: {type(exc)} {error}; traceback: {traceback.format_exc()!r}",
294298
}
295299
)
296300

0 commit comments

Comments
 (0)