Config file changes

This file can now be pushed to the main branch. The following changes have taken place:
1) Removed my personal data.
2) Made it compliant with pydantic 2. This involved:
    a) Changing the way of noting optional strings (now 'none' strings). This is as elegant as is possible.
    b) Updating the imports. Origin code results in "pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.7/migration/#basesettings-has-moved-to-pydantic-settings for more details.
    c) converting urls using the str() method. Origin code results in AttributeError: 'pydantic_core._pydantic_core.Url' object has no attribute 'decode' For further information visit https://errors.pydantic.dev/2.7/u/import-error"

New developers will still need to fill out the mail_address, mail_password, mail_username, mail_port and secret_key before they can run the code. This is by design, though.

Hope this saves time, Mawoka!
This commit is contained in:
BogPlaymate
2024-07-09 17:54:52 +09:00
parent d3e311ede5
commit d7a39513f6
+17 -19
View File
@@ -33,25 +33,23 @@ class Settings(BaseSettings):
redis: RedisDsn = "redis://localhost:6379/0?decode_responses=True"
skip_email_verification: bool = False
db_url: str | PostgresDsn = "postgresql://postgres:mysecretpassword@localhost:5432/classquiz"
hcaptcha_key: str = "3852831a-48b4-4236-b0de-9769a1998468"
hcaptcha_key: str | None = None
recaptcha_key: str | None = None
# mail_address: str
mail_address: str = "778@madeupaddress.com"
# mail_password: str
mail_password: str = "mail_passwordstring"
mail_username: str = "mail_userstring"
mail_server: str = "mail_serverstring"
mail_port: int = 0
secret_key: str = "secret_keystring"
mail_address: str | None = None #from here
mail_password: str | None = None
mail_username: str | None = None
mail_server: str | None = None
mail_port: int | None = None
secret_key: str = "secretkey" # to here
access_token_expire_minutes: int = 30
cache_expiry: int = 86400
sentry_dsn: str = ""
sentry_dsn: str | None = None
meilisearch_url: str = "http://127.0.0.1:7700"
meilisearch_index: str = "classquiz"
google_client_id: str = "google_client_idstring"
google_client_secret: str = "google_client_secretstring"
github_client_id: str = "github_client_idstring"
github_client_secret: str = "github_client_secretstring"
google_client_id: str | None = None
google_client_secret: str | None = None
github_client_id: str | None = None
github_client_secret: str | None = None
custom_openid_provider: CustomOpenIDProvider | None = None
telemetry_enabled: bool = True
free_storage_limit: int = 1074000000
@@ -60,16 +58,16 @@ class Settings(BaseSettings):
registration_disabled: bool = False
# storage_backend
storage_backend: str = "local"
storage_backend: str | None = "local"
# if storage_backend == "local":
storage_path: str = "/tmp/storage"
storage_path: str | None = None
# if storage_backend == "s3":
s3_access_key: str = "s3_access_keystring"
s3_secret_key: str = "s3_secret_keystring"
s3_access_key: str | None = None
s3_secret_key: str | None = None
s3_bucket_name: str = "classquiz"
s3_base_url: str = "s3_base_urlstring"
s3_base_url: str | None = None
class Config:
env_file = ".env"