🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

app-settings-pydantic

Package Overview
Dependencies
Maintainers
0
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-settings-pydantic

A simple configuration management package using `pydantic-settings` and `platformdirs`

1.0.0
PyPI
Maintainers
0

app-settings-pydantic

A simple configuration management package using pydantic-settings and platformdirs.

This package allows you to define application settings in a .env file stored in the user's configuration directory.

Features

  • Automatically determines the appropriate configuration file location using platformdirs
  • Uses pydantic-settings for settings validation and management
  • Supports configuration before use via the configure() function
  • Provides a .save() method to persist settings

Installation

pip install app-settings-pydantic

Usage

1. Configure the app

Before using Settings, you must configure the package with app name and default language.

from app_settings import configure

configure(app_name="my_app", default_language="en")

2. Use the Settings class

from app_settings import Settings

settings = Settings()

3. Save settings

settings.language = "pl"
settings.save()  # Saves to ~/.config/my_app/.env (Linux)

Configuration Path

The configuration file is stored in the user config directory provided by platformdirs, e.g.:

  • Linux: ~/.config/<app_name>/.env
  • macOS: ~/Library/Application Support/<app_name>/.env
  • Windows: C:\Users\<User>\AppData\Local\<app_name>\.env

Fields

Currently, the settings class includes:

  • language: Application language (default from configure(), supports "en" and "pl")

Errors

If configure() is not called before accessing Settings, a RuntimeError will be raised.

License

MIT

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts