2626import logging
2727import sys
2828from typing import TYPE_CHECKING , Any
29+ from urllib .parse import urlparse
2930
3031from click import echo
3132from cloup import (
@@ -52,7 +53,7 @@ def _print_version(
5253 param : Any , # noqa: ANN401, ARG001
5354 value : Any , # noqa: ANN401
5455) -> None :
55- """Prints the version of the package"""
56+ """Prints the version of the package. """
5657 if not value or ctx .resilient_parsing :
5758 return
5859 from importlib .metadata import version # noqa: PLC0415
@@ -62,8 +63,7 @@ def _print_version(
6263
6364
6465def _get_base_url (url : str ) -> str :
65- """Extracts the base URL from a full URL"""
66- from urllib .parse import urlparse # noqa: PLC0415
66+ """Extracts the base URL from a full URL."""
6767
6868 parsed_url = urlparse (url )
6969 if parsed_url .scheme and parsed_url .netloc :
@@ -72,16 +72,16 @@ def _get_base_url(url: str) -> str:
7272
7373
7474def _get_uri_path (url : str ) -> str :
75- """Extracts the URI path from a full URL or returns the URL if it's already a path"""
76- from urllib .parse import urlparse # noqa: PLC0415
75+ """
76+ Extracts the URI path from a full URL or returns the URL if it's already a
77+ path.
78+ """
7779
7880 parsed_url = urlparse (url )
7981 if parsed_url .scheme and parsed_url .netloc :
8082 path = parsed_url .path
8183 if parsed_url .query :
8284 path += f"?{ parsed_url .query } "
83- if parsed_url .fragment :
84- path += f"#{ parsed_url .fragment } "
8585 return path
8686 return url
8787
@@ -188,9 +188,9 @@ def spot(ctx: Context, url: str, **kwargs: dict) -> None: # noqa: ARG001
188188 )
189189 )
190190 except JSONDecodeError as exc :
191- LOG .error (f "Could not parse the passed data. { exc } " ) # noqa: G004
191+ LOG .error ("Could not parse the passed data. %s" , exc )
192192 except Exception as exc : # noqa: BLE001
193- LOG .error (f "Exception occurred: { exc } " ) # noqa: G004
193+ LOG .error ("Exception occurred: %s" , exc )
194194 sys .exit (1 )
195195 else :
196196 echo (response )
@@ -266,9 +266,9 @@ def futures(ctx: Context, url: str, **kwargs: dict) -> None: # noqa: ARG001
266266 )
267267 )
268268 except JSONDecodeError as exc :
269- LOG .error (f "Could not parse the passed data. { exc } " ) # noqa: G004
269+ LOG .error ("Could not parse the passed data. %s" , exc )
270270 except Exception as exc : # noqa: BLE001
271- LOG .error (f "Exception occurred: { exc } " ) # noqa: G004
271+ LOG .error ("Exception occurred: %s" , exc )
272272 sys .exit (1 )
273273 else :
274274 echo (response )
0 commit comments