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..7770288de1 100644 --- a/haystack/utils/url_validation.py +++ b/haystack/utils/url_validation.py @@ -1,6 +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])