formatted project by python-black
This commit is contained in:
+16
-4
@@ -6,6 +6,7 @@ from urllib.parse import urlsplit
|
||||
from pydantic import Field, model_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class S3Settings(BaseSettings):
|
||||
endpoint: str = "http://minio:9000"
|
||||
region: str = "us-east-1"
|
||||
@@ -24,12 +25,23 @@ class S3Settings(BaseSettings):
|
||||
cleanup_grace_seconds: int = Field(default=86_400, ge=300)
|
||||
cleanup_interval_seconds: int = Field(default=300, ge=1)
|
||||
|
||||
model_config = SettingsConfigDict(env_prefix="S3_", env_file=".env", extra="ignore", frozen=True)
|
||||
model_config = SettingsConfigDict(
|
||||
env_prefix="S3_", env_file=".env", extra="ignore", frozen=True
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_endpoint(self):
|
||||
url = urlsplit(self.endpoint)
|
||||
if (url.scheme not in {"http", "https"} or not url.hostname or url.username
|
||||
or url.password or url.path not in {"", "/"} or url.query or url.fragment):
|
||||
raise ValueError("S3_ENDPOINT должен быть http(s) адресом без credentials/пути")
|
||||
if (
|
||||
url.scheme not in {"http", "https"}
|
||||
or not url.hostname
|
||||
or url.username
|
||||
or url.password
|
||||
or url.path not in {"", "/"}
|
||||
or url.query
|
||||
or url.fragment
|
||||
):
|
||||
raise ValueError(
|
||||
"S3_ENDPOINT должен быть http(s) адресом без credentials/пути"
|
||||
)
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user