Changed code to support older Python versions

This commit is contained in:
Malasaur 2025-12-01 23:27:09 +01:00
parent eb92d2d36f
commit 582458cdd0
5027 changed files with 794942 additions and 4 deletions

View file

@ -0,0 +1,26 @@
import json
from pathlib import Path
from pydantic import BaseModel
from .utils.config import get_cli_config_path
class Settings(BaseModel):
base_api_url: str = "https://api.fastapicloud.com/api/v1"
client_id: str = "fastapi-cli"
@classmethod
def from_user_settings(cls, config_path: Path) -> "Settings":
try:
content = config_path.read_bytes() if config_path.exists() else b"{}"
user_settings = json.loads(content)
except json.JSONDecodeError:
user_settings = {}
return cls(**user_settings)
@classmethod
def get(cls) -> "Settings":
return cls.from_user_settings(get_cli_config_path())