Skip to content

Commit

Permalink
fsspec: Remove botocore as a module import (#1609)
Browse files Browse the repository at this point in the history
In case you don't have `botocore` installed.
  • Loading branch information
Fokko authored Feb 8, 2025
1 parent 7596dc5 commit 826a006
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pyiceberg/io/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from copy import copy
from functools import lru_cache, partial
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Expand All @@ -31,8 +32,6 @@
from urllib.parse import urlparse

import requests
from botocore import UNSIGNED
from botocore.awsrequest import AWSRequest
from fsspec import AbstractFileSystem
from fsspec.implementations.local import LocalFileSystem
from requests import HTTPError
Expand Down Expand Up @@ -83,8 +82,11 @@

logger = logging.getLogger(__name__)

if TYPE_CHECKING:
from botocore.awsrequest import AWSRequest

def s3v4_rest_signer(properties: Properties, request: AWSRequest, **_: Any) -> AWSRequest:

def s3v4_rest_signer(properties: Properties, request: "AWSRequest", **_: Any) -> "AWSRequest":
signer_url = properties.get(S3_SIGNER_URI, properties["uri"]).rstrip("/")
signer_endpoint = properties.get(S3_SIGNER_ENDPOINT, S3_SIGNER_ENDPOINT_DEFAULT)

Expand Down Expand Up @@ -114,7 +116,7 @@ def s3v4_rest_signer(properties: Properties, request: AWSRequest, **_: Any) -> A
return request


SIGNERS: Dict[str, Callable[[Properties, AWSRequest], AWSRequest]] = {"S3V4RestSigner": s3v4_rest_signer}
SIGNERS: Dict[str, Callable[[Properties, "AWSRequest"], "AWSRequest"]] = {"S3V4RestSigner": s3v4_rest_signer}


def _file(_: Properties) -> LocalFileSystem:
Expand All @@ -141,6 +143,8 @@ def _s3(properties: Properties) -> AbstractFileSystem:
register_events["before-sign.s3"] = signer_func_with_properties

# Disable the AWS Signer
from botocore import UNSIGNED

config_kwargs["signature_version"] = UNSIGNED
else:
raise ValueError(f"Signer not available: {signer}")
Expand Down

0 comments on commit 826a006

Please sign in to comment.