From d00c34ee7f12b933b64c3b713978bab0045afea9 Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Fri, 6 Feb 2026 03:19:00 +0200 Subject: [PATCH] style(parser): Improve the type hint for `find_by_text` and `find_by_regex` --- scrapling/parser.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/scrapling/parser.py b/scrapling/parser.py index 0edaf94..1ae6db1 100644 --- a/scrapling/parser.py +++ b/scrapling/parser.py @@ -1074,6 +1074,26 @@ class Selector(SelectorsGeneration): return Selectors(map(self.__element_convertor, similar_elements)) + @overload + def find_by_text( + self, + text: str, + first_match: Literal[True] = ..., + partial: bool = ..., + case_sensitive: bool = ..., + clean_match: bool = ..., + ) -> "Selector": ... + + @overload + def find_by_text( + self, + text: str, + first_match: Literal[False], + partial: bool = ..., + case_sensitive: bool = ..., + clean_match: bool = ..., + ) -> "Selectors": ... + def find_by_text( self, text: str, @@ -1122,6 +1142,24 @@ class Selector(SelectorsGeneration): return results[0] return results + @overload + def find_by_regex( + self, + query: str | Pattern[str], + first_match: Literal[True] = ..., + case_sensitive: bool = ..., + clean_match: bool = ..., + ) -> "Selector": ... + + @overload + def find_by_regex( + self, + query: str | Pattern[str], + first_match: Literal[False], + case_sensitive: bool = ..., + clean_match: bool = ..., + ) -> "Selectors": ... + def find_by_regex( self, query: str | Pattern[str],