Skip to content

Commit 86977f9

Browse files
committed
Enable error overlays
1 parent a0c57a8 commit 86977f9

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Lib/_colorize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ class LiveProfiler(ThemeSection):
334334
@dataclass(frozen=True, kw_only=True)
335335
class Syntax(ThemeSection):
336336
prompt: str = ANSIColors.BOLD_MAGENTA
337+
error: str = ANSIColors.BOLD_RED
337338
keyword: str = ANSIColors.BOLD_BLUE
338339
keyword_constant: str = ANSIColors.BOLD_BLUE
339340
builtin: str = ANSIColors.CYAN

Lib/_pyrepl/reader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class Reader:
196196
ps3: str = "|.. "
197197
ps4: str = R"\__ "
198198
kill_ring: list[list[str]] = field(default_factory=list)
199+
error_prefix: str = "! "
199200
msg: str = ""
200201
arg: int | None = None
201202
dirty: bool = False
@@ -641,7 +642,11 @@ def finish(self) -> None:
641642
pass
642643

643644
def error(self, msg: str = "none") -> None:
644-
self.msg = "! " + msg + " "
645+
error_prefix = self.error_prefix
646+
if self.can_colorize:
647+
t = THEME()
648+
error_prefix = f"{t.error}{error_prefix}{t.reset}"
649+
self.msg = error_prefix + msg
645650
self.dirty = True
646651
self.console.beep()
647652

Lib/_pyrepl/readline.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ def __post_init__(self) -> None:
124124
self.commands["backspace_dedent"] = backspace_dedent
125125
self.commands["backspace-dedent"] = backspace_dedent
126126

127-
def error(self, msg: str = "none") -> None:
128-
pass # don't show error messages by default
129-
130127
def get_stem(self) -> str:
131128
b = self.buffer
132129
p = self.pos - 1

0 commit comments

Comments
 (0)