Skip to content

Commit

Permalink
style(TextHandler): Setting overload on check_match argument for auto…
Browse files Browse the repository at this point in the history
… completion
  • Loading branch information
D4Vinci committed Jan 30, 2025
1 parent e507778 commit 7882cf2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions scrapling/core/custom_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
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
Expand Down Expand Up @@ -127,6 +127,28 @@ def json(self) -> Dict:
# 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
Expand Down

0 comments on commit 7882cf2

Please # to comment.