2323from copy import copy
2424from functools import lru_cache , partial
2525from typing import (
26+ TYPE_CHECKING ,
2627 Any ,
2728 Callable ,
2829 Dict ,
3132from urllib .parse import urlparse
3233
3334import requests
34- from botocore import UNSIGNED
35- from botocore .awsrequest import AWSRequest
3635from fsspec import AbstractFileSystem
3736from fsspec .implementations .local import LocalFileSystem
3837from requests import HTTPError
8382
8483logger = logging .getLogger (__name__ )
8584
85+ if TYPE_CHECKING :
86+ from botocore .awsrequest import AWSRequest
8687
87- def s3v4_rest_signer (properties : Properties , request : AWSRequest , ** _ : Any ) -> AWSRequest :
88+
89+ def s3v4_rest_signer (properties : Properties , request : "AWSRequest" , ** _ : Any ) -> "AWSRequest" :
8890 signer_url = properties .get (S3_SIGNER_URI , properties ["uri" ]).rstrip ("/" )
8991 signer_endpoint = properties .get (S3_SIGNER_ENDPOINT , S3_SIGNER_ENDPOINT_DEFAULT )
9092
@@ -114,7 +116,7 @@ def s3v4_rest_signer(properties: Properties, request: AWSRequest, **_: Any) -> A
114116 return request
115117
116118
117- SIGNERS : Dict [str , Callable [[Properties , AWSRequest ], AWSRequest ]] = {"S3V4RestSigner" : s3v4_rest_signer }
119+ SIGNERS : Dict [str , Callable [[Properties , " AWSRequest" ], " AWSRequest" ]] = {"S3V4RestSigner" : s3v4_rest_signer }
118120
119121
120122def _file (_ : Properties ) -> LocalFileSystem :
@@ -141,6 +143,8 @@ def _s3(properties: Properties) -> AbstractFileSystem:
141143 register_events ["before-sign.s3" ] = signer_func_with_properties
142144
143145 # Disable the AWS Signer
146+ from botocore import UNSIGNED
147+
144148 config_kwargs ["signature_version" ] = UNSIGNED
145149 else :
146150 raise ValueError (f"Signer not available: { signer } " )
0 commit comments