(self, syntax_error: _SyntaxError)
| 727 | |
| 728 | @group() |
| 729 | def _render_syntax_error(self, syntax_error: _SyntaxError) -> RenderResult: |
| 730 | highlighter = ReprHighlighter() |
| 731 | path_highlighter = PathHighlighter() |
| 732 | if syntax_error.filename != "<stdin>": |
| 733 | if os.path.exists(syntax_error.filename): |
| 734 | text = Text.assemble( |
| 735 | (f" {syntax_error.filename}", "pygments.string"), |
| 736 | (":", "pygments.text"), |
| 737 | (str(syntax_error.lineno), "pygments.number"), |
| 738 | style="pygments.text", |
| 739 | ) |
| 740 | yield path_highlighter(text) |
| 741 | syntax_error_text = highlighter(syntax_error.line.rstrip()) |
| 742 | syntax_error_text.no_wrap = True |
| 743 | offset = min(syntax_error.offset - 1, len(syntax_error_text)) |
| 744 | syntax_error_text.stylize("bold underline", offset, offset) |
| 745 | syntax_error_text += Text.from_markup( |
| 746 | "\n" + " " * offset + "[traceback.offset]▲[/]", |
| 747 | style="pygments.text", |
| 748 | ) |
| 749 | yield syntax_error_text |
| 750 | |
| 751 | @classmethod |
| 752 | def _guess_lexer(cls, filename: str, code: str) -> str: |
no test coverage detected