@@ -28,17 +28,17 @@ def build_request_url(gateway: str, request_url: str) -> str:
2828 if parsed_url .host != "ipfs" :
2929 host = parsed_url .host
3030 # Remove duplicate slashes
31- if url .endswith ("/" ) and host .startswith ("/" ):
32- host = host [1 :]
33- url += host
31+ if url .endswith ("/" ) and host .startswith ("/" ): # type: ignore[union-attr]
32+ host = host [1 :] # type: ignore[index]
33+ url += host # type: ignore[operator]
3434 if parsed_url .path is not None :
3535 path = parsed_url .path
3636 # Remove duplicate slashes
3737 if url .endswith ("/" ) and path .startswith ("/" ):
3838 path = path [1 :]
3939 url += path
4040 # Handle "https://" prefixed urls that have "/ipfs/" in the path
41- elif parsed_url .scheme == "https" and "ipfs" in parsed_url .path :
41+ elif parsed_url .scheme == "https" and "ipfs" in parsed_url .path : # type: ignore[operator] # noqa: E501
4242 url = f"{ gateway } "
4343 if parsed_url .path is not None :
4444 path = parsed_url .path
@@ -60,9 +60,9 @@ class IPFSAdapter(HTTPAdapter):
6060 key (str, optional): optional key to send with request
6161 secret (str, optional): optional secret to send with request
6262 timeout (int): request timeout in seconds. Defaults to 10 seconds.
63- """
63+ """ # noqa: E501
6464
65- def __init__ (
65+ def __init__ ( # type: ignore[no-untyped-def]
6666 self ,
6767 host_prefixes : Optional [list [str ]] = None ,
6868 key : Optional [str ] = None ,
@@ -96,7 +96,7 @@ def make_request_url(self, request_url: str, gateway: Optional[str] = None) -> s
9696 gateway = gateway or random .choice (self .host_prefixes )
9797 return build_request_url (gateway = gateway , request_url = request_url )
9898
99- async def gen_send (self , url : str , sess : httpx .AsyncClient (), * args , ** kwargs ) -> httpx .Response :
99+ async def gen_send (self , url : str , sess : httpx .AsyncClient (), * args , ** kwargs ) -> httpx .Response : # type: ignore[no-untyped-def, valid-type] # noqa: E501
100100 """Format and send async request to IPFS host.
101101
102102 Args:
@@ -106,9 +106,9 @@ async def gen_send(self, url: str, sess: httpx.AsyncClient(), *args, **kwargs) -
106106 Returns:
107107 httpx.Response: response from IPFS host.
108108 """
109- return await sess .get (self .make_request_url (url ), timeout = self .timeout , follow_redirects = True )
109+ return await sess .get (self .make_request_url (url ), timeout = self .timeout , follow_redirects = True ) # type: ignore[no-any-return] # noqa: E501
110110
111- def send (self , request : PreparedRequest , * args , ** kwargs ) -> Response :
111+ def send (self , request : PreparedRequest , * args , ** kwargs ) -> Response : # type: ignore[no-untyped-def] # noqa: E501
112112 """For IPFS hashes, query pinata cloud gateway
113113
114114 Args:
@@ -117,7 +117,7 @@ def send(self, request: PreparedRequest, *args, **kwargs) -> Response:
117117 Returns:
118118 Response: response from IPFS Gateway
119119 """
120- request .url = self .make_request_url (request .url )
120+ request .url = self .make_request_url (request .url ) # type: ignore[arg-type]
121121
122122 kwargs ["timeout" ] = self .timeout
123123 return super ().send (request , * args , ** kwargs )
0 commit comments