Method: rich.traceback.Traceback._render_syntax_error
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
_SyntaxError (1)
Text (2) None (1)
1@group()
2 def _render_syntax_error(self, syntax_error: _SyntaxError) -> RenderResult:
3 highlighter = ReprHighlighter()
4 path_highlighter = PathHighlighter()
5 if syntax_error.filename != "<stdin>":
6 text = Text.assemble(
7 (f" {syntax_error.filename}", "pygments.string"),
8 (":", "pygments.text"),
9 (str(syntax_error.lineno), "pygments.number"),
10 style="pygments.text",
11 )
12 yield path_highlighter(text)
13 syntax_error_text = highlighter(syntax_error.line.rstrip())
14 syntax_error_text.no_wrap = True
15 offset = min(syntax_error.offset - 1, len(syntax_error_text))
16 syntax_error_text.stylize("bold underline", offset, offset)
17 syntax_error_text += Text.from_markup(
18 "\n" + " " * offset + "[traceback.offset]▲[/]",
19 style="pygments.text",
20 )
21 yield syntax_error_text