From 6e7969fcb6f184ca0fb0b8b14ee757e73f347b16 Mon Sep 17 00:00:00 2001 From: "Xavier G." Date: Tue, 24 Sep 2024 12:31:19 +0200 Subject: [PATCH] Adjust Log.highlighter type to allow for custom highlighters. Without an explicit type, tools like mypy assume Log.highlighter must be a ReprHighlighter instead of a Highlighter. --- src/textual/widgets/_log.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textual/widgets/_log.py b/src/textual/widgets/_log.py index b12d6344da..ee50fd87ed 100644 --- a/src/textual/widgets/_log.py +++ b/src/textual/widgets/_log.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Iterable, Optional, Sequence from rich.cells import cell_len -from rich.highlighter import ReprHighlighter +from rich.highlighter import Highlighter, ReprHighlighter from rich.segment import Segment from rich.style import Style from rich.text import Text @@ -70,7 +70,7 @@ def __init__( self._width = 0 self._updates = 0 self._render_line_cache: LRUCache[int, Strip] = LRUCache(1024) - self.highlighter = ReprHighlighter() + self.highlighter: Highlighter = ReprHighlighter() """The Rich Highlighter object to use, if `highlight=True`""" @property