Skip to content

Commit

Permalink
Adjust RichLog.highlighter type to allow for custom highlighters.
Browse files Browse the repository at this point in the history
Without an explicit type, tools like mypy assume RichLog.highlighter must be a ReprHighlighter instead of a Highlighter.
  • Loading branch information
xavierog authored Mar 1, 2024
1 parent c27a3b4 commit e6631fa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/textual/widgets/_rich_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TYPE_CHECKING, Optional, cast

from rich.console import RenderableType
from rich.highlighter import ReprHighlighter
from rich.highlighter import Highlighter, ReprHighlighter
from rich.measure import measure_renderables
from rich.pretty import Pretty
from rich.protocol import is_renderable
Expand Down Expand Up @@ -86,7 +86,8 @@ def __init__(
"""Apply Rich console markup."""
self.auto_scroll = auto_scroll
"""Automatically scroll to the end on write."""
self.highlighter = ReprHighlighter()
self.highlighter: Highlighter = ReprHighlighter()
"""Rich Highlighter used to highlight content when highlight is True"""

self._last_container_width: int = min_width
"""Record the last width we rendered content at."""
Expand Down

0 comments on commit e6631fa

Please sign in to comment.