Skip to content

Commit 241d473

Browse files
committed
fsspec: Remove botocore as a module import
In case you don't have `botocore` installed.
1 parent 5018efc commit 241d473

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pyiceberg/io/fsspec.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from copy import copy
2424
from functools import lru_cache, partial
2525
from typing import (
26+
TYPE_CHECKING,
2627
Any,
2728
Callable,
2829
Dict,
@@ -31,8 +32,6 @@
3132
from urllib.parse import urlparse
3233

3334
import requests
34-
from botocore import UNSIGNED
35-
from botocore.awsrequest import AWSRequest
3635
from fsspec import AbstractFileSystem
3736
from fsspec.implementations.local import LocalFileSystem
3837
from requests import HTTPError
@@ -83,8 +82,11 @@
8382

8483
logger = 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

120122
def _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

Comments
 (0)