From 64814583e47b40d2d132015c91a8d70fe70bc55b Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Mon, 8 Apr 2024 10:29:31 +0200 Subject: [PATCH 1/2] just some more quick fixes --- haystack/utils/callable_serialization.py | 2 ++ haystack/utils/hf.py | 7 +++++++ haystack/utils/url_validation.py | 1 + 3 files changed, 10 insertions(+) diff --git a/haystack/utils/callable_serialization.py b/haystack/utils/callable_serialization.py index e919f61499..f2f83a768c 100644 --- a/haystack/utils/callable_serialization.py +++ b/haystack/utils/callable_serialization.py @@ -8,6 +8,7 @@ def serialize_callable(callable_handle: Callable) -> str: """ Serializes a callable to its full path. + :param callable_handle: The callable to serialize :return: The full path of the callable """ @@ -24,6 +25,7 @@ def serialize_callable(callable_handle: Callable) -> str: def deserialize_callable(callable_handle: str) -> Optional[Callable]: """ Deserializes a callable given its full import path as a string. + :param callable_handle: The full path of the callable_handle :return: The callable :raises DeserializationError: If the callable cannot be found diff --git a/haystack/utils/hf.py b/haystack/utils/hf.py index b941a742f0..60cc474457 100644 --- a/haystack/utils/hf.py +++ b/haystack/utils/hf.py @@ -40,6 +40,13 @@ def __str__(self): @staticmethod def from_str(string: str) -> "HFGenerationAPIType": + """ + Convert a string to a HFGenerationAPIType enum. + + :param string: The string to convert. + :return: The corresponding HFGenerationAPIType enum. + + """ enum_map = {e.value: e for e in HFGenerationAPIType} mode = enum_map.get(string) if mode is None: diff --git a/haystack/utils/url_validation.py b/haystack/utils/url_validation.py index 6d4c9e69d5..be062a9d87 100644 --- a/haystack/utils/url_validation.py +++ b/haystack/utils/url_validation.py @@ -2,5 +2,6 @@ def is_valid_http_url(url) -> bool: + """Check if a URL is a valid HTTP/HTTPS URL.""" r = urlparse(url) return all([r.scheme in ["http", "https"], r.netloc]) From f250455ded1b915ca42e01523e8714d86a946d34 Mon Sep 17 00:00:00 2001 From: "David S. Batista" Date: Mon, 8 Apr 2024 10:41:19 +0200 Subject: [PATCH 2/2] Update haystack/utils/url_validation.py Co-authored-by: Madeesh Kannan --- haystack/utils/url_validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haystack/utils/url_validation.py b/haystack/utils/url_validation.py index be062a9d87..7770288de1 100644 --- a/haystack/utils/url_validation.py +++ b/haystack/utils/url_validation.py @@ -1,7 +1,7 @@ from urllib.parse import urlparse -def is_valid_http_url(url) -> bool: +def is_valid_http_url(url: str) -> bool: """Check if a URL is a valid HTTP/HTTPS URL.""" r = urlparse(url) return all([r.scheme in ["http", "https"], r.netloc])