Skip to content

Commit 9e88b8e

Browse files
committed
Clean up settings.py
1 parent a67375e commit 9e88b8e

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

jsoned/settings.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
from typing import Annotated, Any
2-
3-
from pydantic import AnyHttpUrl, BeforeValidator
1+
from pydantic import AnyHttpUrl
42
from pydantic_settings import BaseSettings
53

64

7-
def parse_cors(v: Any) -> list[str] | str:
8-
if isinstance(v, str) and not v.startswith("["):
9-
return [i.strip() for i in v.split(",")]
10-
elif isinstance(v, list | str):
11-
return v
12-
raise ValueError(v)
13-
14-
155
class Settings(BaseSettings):
166
PROJECT_NAME: str = "JSONed"
177
API_V1_STR: str = "/api/v1"
18-
BACKEND_CORS_ORIGINS: Annotated[
19-
list[AnyHttpUrl] | str, BeforeValidator(parse_cors)
20-
] = ["http://localhost", "http://localhost:3000"]
8+
BACKEND_CORS_ORIGINS: list[AnyHttpUrl] = [
9+
"http://localhost",
10+
"http://localhost:3000",
11+
]
2112

2213

2314
settings = Settings()

0 commit comments

Comments
 (0)