Skip to main content

A Python library to save your settings in a TOML file.

Project description

Simple TOML Settings

PyPI version Test Suite Codacy Coverage Codacy Badge CodeQL

A Python library to save your settings in a TOML file.

Development Status

Note that there is still additional functionality planned to be added to this package, but the methodology is to keep the package simple to use and understand. Any additional functionality will be added in a way that is backward compatible and optional.

The package is considered stable and is being used in production in several non-trivial applications.

Please report any bugs you find on the issue tracker and feel free to make suggestions for improvements.

Installation

You should install this package into a virtual environment. You can use uv (recommended), or Poetry to do this:

$ uv add simple-toml-settings

or

$ poetry add simple-toml-settings

If you don't want to use Poetry, you can use pip from inside your virtual environment:

$ pip install simple-toml-settings

Usage

This is a library to save your settings in a TOML file. It is designed to be simple to use and to be able to save and load settings from a TOML file with a minimal of configuration.

The below is a minimal example, for full documentation and information on available options, see the documentation site. There are several flags you can set to change the location of the settings file, the name of the file, allowing to run without a settings file, and more.

Usage is simple:

Setup

from simple_toml_settings import TOMLSettings

class MySettings(TOMLSettings):
    """My settings class."""

    # Define the settings you want to save
    name: str = "My Name"
    age: int = 42
    favourite_colour: str = "blue"
    favourite_number: int = 42
    favourite_foods: list = ["pizza", "chocolate", "ice cream"]


settings = MySettings("test_app")

The above will automatically create a TOML file in the user's home directory called config.toml, in the subdirectory .test_app/, and save the settings to it. If the file already exists, the settings will be loaded from it.

The file contents for the above example would be:

[test_app]
age = 42
favourite_colour = "blue"
favourite_number = 42
name = "My Name"
schema_version = "none"
favourite_foods = ["pizza", "chocolate", "ice cream"]

Using the settings

Once you have created your settings class, you can use it like any other class:

settings = MySettings("test_app")
settings.favourite_colour = "red"
settings.save()

Development setup

See the Contributing Guidelines for details of how to contribute to this project and set it up for development.

License

This project is released under the terms of the MIT license.

Credits

The original Python boilerplate for this package was created using Pymaker by Grant Ramsay (seapagan) (Me!! 😄).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_toml_settings-0.12.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_toml_settings-0.12.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file simple_toml_settings-0.12.0.tar.gz.

File metadata

  • Download URL: simple_toml_settings-0.12.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simple_toml_settings-0.12.0.tar.gz
Algorithm Hash digest
SHA256 bf375761386177c86b9cd87340d05a80f58990524a65d2392ee979acbfc2538f
MD5 2e39e34f248fb4ad38c80c70afc30a96
BLAKE2b-256 666af62fdc215afe3c6dba22af144e1b5e430969840c1e86fef34a2e94a9997b

See more details on using hashes here.

File details

Details for the file simple_toml_settings-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: simple_toml_settings-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simple_toml_settings-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 450a99e5b3624b218f492e2f5ec1b3954c86a47bb0537f905e1b09cea8a924b0
MD5 ff14898a8525949040053dc1eb77dc0e
BLAKE2b-256 8e3d7bf67f9158e77bb91a43cefb7753a6c177d92740905b1ed2f2af3a948ba1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page