Skip to content

🕷️ The BEST Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev

style(TextHandler): Setting overload on check_match argument for auto completion

Karim shoair7882cf25279d
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