fix: moving types to use Union again

This commit is contained in:
Karim shoair
2025-07-30 05:39:25 +03:00
parent 27658b33ff
commit af5f3688c1
2 changed files with 13 additions and 11 deletions
+5 -3
View File
@@ -1,6 +1,6 @@
from collections.abc import Mapping
from types import MappingProxyType
from re import compile as re_compile, sub, UNICODE, IGNORECASE
from re import compile as re_compile, UNICODE, IGNORECASE
from orjson import dumps, loads
@@ -165,7 +165,7 @@ class TextHandler(str):
clean_match: bool = False,
case_sensitive: bool = True,
check_match: bool = False,
) -> "TextHandlers" | bool:
) -> Union["TextHandlers", bool]:
"""Apply the given regex to the current text and return a list of strings with the matches.
:param regex: Can be either a compiled regular expression or a string.
@@ -244,7 +244,9 @@ class TextHandlers(List[TextHandler]):
def __getitem__(self, pos: slice) -> "TextHandlers":
pass
def __getitem__(self, pos: SupportsIndex | slice) -> TextHandler | "TextHandlers":
def __getitem__(
self, pos: SupportsIndex | slice
) -> Union[TextHandler, "TextHandlers"]:
lst = super().__getitem__(pos)
if isinstance(pos, slice):
lst = [TextHandler(s) for s in lst]