Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions airflow/providers/amazon/aws/hooks/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def wrapper(*args, **kwargs) -> T:
bound_args.arguments["bucket_name"] = self.service_config["bucket_name"]
elif self.conn_config and self.conn_config.schema:
warnings.warn(
"s3 conn_type, and the associated schema field, is deprecated."
" Please use aws conn_type instead, and specify `bucket_name`"
" in `service_config.s3` within `extras`.",
"s3 conn_type, and the associated schema field, is deprecated. "
"Please use aws conn_type instead, and specify `bucket_name` "
"in `service_config.s3` within `extras`.",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -220,7 +220,7 @@ def parse_s3_url(s3url: str) -> tuple[str, str]:
if not parsed_url.netloc:
raise S3HookUriParseFailure(
"Please provide a bucket name using a valid format of the form: "
+ f'{valid_s3_format} or {valid_s3_virtual_hosted_format} but provided: "{s3url}"'
f'{valid_s3_format} or {valid_s3_virtual_hosted_format} but provided: "{s3url}"'
)

bucket_name = parsed_url.netloc
Expand All @@ -236,13 +236,13 @@ def parse_s3_url(s3url: str) -> tuple[str, str]:
key = "/".join(format[1].split("/")[1:])
else:
raise S3HookUriParseFailure(
"Please provide a bucket name using a valid virtually hosted format which should"
+ f' be of the form: {valid_s3_virtual_hosted_format} but provided: "{s3url}"'
"Please provide a bucket name using a valid virtually hosted format which should "
f'be of the form: {valid_s3_virtual_hosted_format} but provided: "{s3url}"'
)
else:
raise S3HookUriParseFailure(
"Please provide a bucket name using a valid format of the form: "
+ f'{valid_s3_format} or {valid_s3_virtual_hosted_format} but provided: "{s3url}"'
f'{valid_s3_format} or {valid_s3_virtual_hosted_format} but provided: "{s3url}"'
)
return bucket_name, key

Expand Down
8 changes: 5 additions & 3 deletions tests/providers/amazon/aws/hooks/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ def test_parse_s3_url_virtual_hosted_style(self):
def test_parse_invalid_s3_url_virtual_hosted_style(self):
with pytest.raises(
S3HookUriParseFailure,
match="Please provide a bucket name using a valid virtually hosted format which should"
+ " be of the form: https://bucket-name.s3.region-code.amazonaws.com/key-name but "
+ 'provided: "https://DOC-EXAMPLE-BUCKET1.us-west-2.amazonaws.com/test.png"',
match=(
"Please provide a bucket name using a valid virtually hosted format which should "
"be of the form: https://bucket-name.s3.region-code.amazonaws.com/key-name but "
'provided: "https://DOC-EXAMPLE-BUCKET1.us-west-2.amazonaws.com/test.png"'
),
):
S3Hook.parse_s3_url("https://DOC-EXAMPLE-BUCKET1.us-west-2.amazonaws.com/test.png")

Expand Down