diff --git a/HISTORY.md b/HISTORY.md index 70eedb1e..e41a6a9e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,7 @@ ## UNRELEASED +- Delegated `AWS_ENDPOINT_URL` handling to boto3 now that the AWS SDK supports endpoint environment variables directly (Issue [#194](https://github.com/drivendataorg/cloudpathlib/issues/194)). - Fixed mypy 2.x type errors in `Client` and `CloudPath` that caused CI lint failures (Issue [#563](https://github.com/drivendataorg/cloudpathlib/issues/563), PR [#566](https://github.com/drivendataorg/cloudpathlib/pull/566)) - Changed `S3Client._get_metadata` to read object metadata with `HeadObject` instead of `GetObject`, so `stat`, `etag`, and `size` no longer open the object body. Also fixes a `KeyError` on `ContentLength` against S3-compatible gateways that drop `Content-Length` from `GetObject` responses. (Issue [#564](https://github.com/drivendataorg/cloudpathlib/issues/564), PR [#565](https://github.com/drivendataorg/cloudpathlib/pull/565)) diff --git a/cloudpathlib/s3/s3client.py b/cloudpathlib/s3/s3client.py index 6d052273..12521a3c 100644 --- a/cloudpathlib/s3/s3client.py +++ b/cloudpathlib/s3/s3client.py @@ -79,7 +79,6 @@ def __init__( args that are supported look at the upload and download lists in the [boto3 docs](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/s3.html#boto3.s3.transfer.S3Transfer). """ - endpoint_url = endpoint_url or os.getenv("AWS_ENDPOINT_URL") if boto3_session is not None: self.sess = boto3_session else: diff --git a/tests/test_s3_specific.py b/tests/test_s3_specific.py index 7e9bd324..0dca63ed 100644 --- a/tests/test_s3_specific.py +++ b/tests/test_s3_specific.py @@ -254,12 +254,10 @@ def test_extra_args_via_requester_pays(s3_rig, tmp_path): def test_aws_endpoint_url_env(monkeypatch): - """Allows setting endpoint_url from env variable - until upstream boto3 PR is merged. - https://github.com/boto/boto3/pull/2746 - """ + """Delegates AWS_ENDPOINT_URL handling to boto3.""" s3_url = "https://s3.amazonaws.com" localstack_url = "http://localhost:4566" + explicit_url = "http://localhost:9000" s3_client = S3Client() assert s3_client.client.meta.endpoint_url == s3_url @@ -268,6 +266,9 @@ def test_aws_endpoint_url_env(monkeypatch): s3_client_custom_endpoint = S3Client() assert s3_client_custom_endpoint.client.meta.endpoint_url == localstack_url + s3_client_explicit_endpoint = S3Client(endpoint_url=explicit_url) + assert s3_client_explicit_endpoint.client.meta.endpoint_url == explicit_url + def test_as_url_local(monkeypatch): path = S3Path("s3://arxiv/pdf")