From aae4e6447eb18d1181ab76b72c761aaa950a7d88 Mon Sep 17 00:00:00 2001 From: SudheerKovvuru Date: Thu, 8 Jan 2026 17:14:03 +0530 Subject: [PATCH 1/2] Fix typing of RegexHighlighter.highlights using ClassVar --- rich/highlighter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rich/highlighter.py b/rich/highlighter.py index e4c462e2b6..8cd391544b 100644 --- a/rich/highlighter.py +++ b/rich/highlighter.py @@ -1,6 +1,6 @@ import re from abc import ABC, abstractmethod -from typing import List, Union +from typing import ClassVar, Union from .text import Span, Text @@ -61,7 +61,7 @@ def highlight(self, text: Text) -> None: class RegexHighlighter(Highlighter): """Applies highlighting from a list of regular expressions.""" - highlights: List[str] = [] + highlights: ClassVar[tuple[str | re.Pattern[str], ...]] = () base_style: str = "" def highlight(self, text: Text) -> None: From da112665abe9f2cd27ba4e121deaeae92c4cee68 Mon Sep 17 00:00:00 2001 From: SudheerKovvuru Date: Thu, 22 Jan 2026 22:13:20 +0530 Subject: [PATCH 2/2] Adjust highlights type to tuple[str] per review --- rich/highlighter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rich/highlighter.py b/rich/highlighter.py index 8cd391544b..c86c3dacd7 100644 --- a/rich/highlighter.py +++ b/rich/highlighter.py @@ -61,7 +61,7 @@ def highlight(self, text: Text) -> None: class RegexHighlighter(Highlighter): """Applies highlighting from a list of regular expressions.""" - highlights: ClassVar[tuple[str | re.Pattern[str], ...]] = () + highlights: ClassVar[tuple[str, ...]] = () base_style: str = "" def highlight(self, text: Text) -> None: