Skip to content

Settings

Settings

Bases: BaseSettings

Configuration settings for the application.

This class is used to define and validate application settings using Pydantic's BaseSettings functionality. Settings are loaded from an environment file specified in the configuration.

Attributes:

Name Type Description
API_KEY str

The API key used for authentication.

USER_AGENT str

The user agent string to be used in HTTP requests.

Config
  • env_file is '.env': Path to the environment file from which to load the settings. In this case, it will need to be created a '.env' file in project root.
  • extra is 'ignored': How to handle extra fields. In this case, extra fields in the environment file will be ignored.
Source code in pylastfmapi/settings.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Settings(BaseSettings):
    """
    Configuration settings for the application.

    This class is used to define and validate application settings using
    Pydantic's `BaseSettings` functionality. Settings are loaded from an
    environment file specified in the configuration.

    Attributes:
        API_KEY (str): The API key used for authentication.
        USER_AGENT (str): The user agent string to be used in HTTP requests.

    Config:
        - `env_file` is '.env': Path to the environment file from which
            to load the settings. In this case, it will need to be created a
            '.env' file in project root.
        - `extra` is 'ignored': How to handle extra fields. In this case, extra
            fields in the environment file will be ignored.
    """

    model_config = SettingsConfigDict(env_file='.env', extra='ignore')
    API_KEY: str
    USER_AGENT: str