Skip to content

Commit fdeee61

Browse files
tarunravicharlesahn-scale
authored andcommitted
fix: use Literal type for s3 addressing_style to satisfy mypy
1 parent 04e9c6d commit fdeee61

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • model-engine/model_engine_server/infra/gateways

model-engine/model_engine_server/infra/gateways/s3_utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import os
2-
from typing import Any, Dict, Optional
2+
from typing import Any, Dict, Literal, Optional, cast
33

44
import boto3
55
from botocore.config import Config
66
from model_engine_server.core.config import infra_config
77

88
_s3_config_logged = False
99

10+
AddressingStyle = Literal["auto", "virtual", "path"]
11+
1012

1113
def _get_onprem_client_kwargs() -> Dict[str, Any]:
1214
global _s3_config_logged
1315
client_kwargs: Dict[str, Any] = {}
1416

15-
s3_endpoint = getattr(infra_config(), "s3_endpoint_url", None) or os.getenv("S3_ENDPOINT_URL")
17+
s3_endpoint = getattr(infra_config(), "s3_endpoint_url", None) or os.getenv(
18+
"S3_ENDPOINT_URL"
19+
)
1620
if s3_endpoint:
1721
client_kwargs["endpoint_url"] = s3_endpoint
1822

19-
addressing_style: str = getattr(infra_config(), "s3_addressing_style", "path")
23+
addressing_style = cast(
24+
AddressingStyle, getattr(infra_config(), "s3_addressing_style", "path")
25+
)
2026
client_kwargs["config"] = Config(s3={"addressing_style": addressing_style})
2127

2228
if not _s3_config_logged and s3_endpoint:

0 commit comments

Comments
 (0)