diff --git a/scrapling/core/custom_types.py b/scrapling/core/custom_types.py index d1ad2c1..03257c3 100644 --- a/scrapling/core/custom_types.py +++ b/scrapling/core/custom_types.py @@ -6,8 +6,8 @@ from types import MappingProxyType from orjson import dumps, loads from w3lib.html import replace_entities as _replace_entities -from scrapling.core._types import (Dict, Iterable, List, Optional, Pattern, - SupportsIndex, TypeVar, Union) +from scrapling.core._types import (Dict, Iterable, List, Literal, Optional, + Pattern, SupportsIndex, TypeVar, Union) from scrapling.core.utils import _is_iterable, flatten # Define type variable for AttributeHandler value type @@ -127,6 +127,28 @@ class TextHandler(str): # Check this out: https://github.com/ijl/orjson/issues/445 return loads(str(self)) + @typing.overload + def re( + self, + regex: Union[str, Pattern[str]], + replace_entities: bool = True, + clean_match: bool = False, + case_sensitive: bool = False, + check_match: Literal[True] = True, + ) -> bool: + ... + + @typing.overload + def re( + self, + regex: Union[str, Pattern[str]], + replace_entities: bool = True, + clean_match: bool = False, + case_sensitive: bool = False, + check_match: Literal[False] = False, + ) -> "TextHandlers[TextHandler]": + ... + def re( self, regex: Union[str, Pattern[str]], replace_entities: bool = True, clean_match: bool = False, case_sensitive: bool = False, check_match: bool = False