Complete the code to load environment variables using Pydantic BaseSettings.
from pydantic import BaseSettings class Settings(BaseSettings): app_name: str settings = Settings([1])
The env_file parameter tells Pydantic to load variables from a .env file.
Complete the code to access the environment variable DATABASE_URL from settings.
from pydantic import BaseSettings class Settings(BaseSettings): database_url: str settings = Settings(env_file='.env') print(settings.[1])
Attributes in the Settings class are accessed using lowercase snake_case names.
Fix the error in the code to correctly load environment variables with a custom .env file.
from pydantic import BaseSettings class Settings(BaseSettings): secret_key: str settings = Settings([1]='config.env')
The correct parameter name to specify a custom environment file is env_file.
Fill both blanks to create a settings class that reads API_KEY and DEBUG from environment variables.
from pydantic import BaseSettings class Settings(BaseSettings): api_key: [1] debug: [2] settings = Settings(env_file='.env')
api_key is a string and debug is a boolean flag.
Fill all three blanks to create a settings class that loads HOST, PORT, and USE_SSL with correct types.
from pydantic import BaseSettings class Settings(BaseSettings): host: [1] port: [2] use_ssl: [3] settings = Settings(env_file='.env')
host is a string, port is an integer, and use_ssl is a boolean.