23
23
from copy import copy
24
24
from functools import lru_cache , partial
25
25
from typing import (
26
+ TYPE_CHECKING ,
26
27
Any ,
27
28
Callable ,
28
29
Dict ,
31
32
from urllib .parse import urlparse
32
33
33
34
import requests
34
- from botocore import UNSIGNED
35
- from botocore .awsrequest import AWSRequest
36
35
from fsspec import AbstractFileSystem
37
36
from fsspec .implementations .local import LocalFileSystem
38
37
from requests import HTTPError
83
82
84
83
logger = logging .getLogger (__name__ )
85
84
85
+ if TYPE_CHECKING :
86
+ from botocore .awsrequest import AWSRequest
86
87
87
- def s3v4_rest_signer (properties : Properties , request : AWSRequest , ** _ : Any ) -> AWSRequest :
88
+
89
+ def s3v4_rest_signer (properties : Properties , request : "AWSRequest" , ** _ : Any ) -> "AWSRequest" :
88
90
signer_url = properties .get (S3_SIGNER_URI , properties ["uri" ]).rstrip ("/" )
89
91
signer_endpoint = properties .get (S3_SIGNER_ENDPOINT , S3_SIGNER_ENDPOINT_DEFAULT )
90
92
@@ -114,7 +116,7 @@ def s3v4_rest_signer(properties: Properties, request: AWSRequest, **_: Any) -> A
114
116
return request
115
117
116
118
117
- SIGNERS : Dict [str , Callable [[Properties , AWSRequest ], AWSRequest ]] = {"S3V4RestSigner" : s3v4_rest_signer }
119
+ SIGNERS : Dict [str , Callable [[Properties , " AWSRequest" ], " AWSRequest" ]] = {"S3V4RestSigner" : s3v4_rest_signer }
118
120
119
121
120
122
def _file (_ : Properties ) -> LocalFileSystem :
@@ -141,6 +143,8 @@ def _s3(properties: Properties) -> AbstractFileSystem:
141
143
register_events ["before-sign.s3" ] = signer_func_with_properties
142
144
143
145
# Disable the AWS Signer
146
+ from botocore import UNSIGNED
147
+
144
148
config_kwargs ["signature_version" ] = UNSIGNED
145
149
else :
146
150
raise ValueError (f"Signer not available: { signer } " )
0 commit comments