All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- /
1.3.0 - 2024-07-14
Added new method get_envs
that returns all the environment variables set in a dict.
>>> settings.get_envs()
{'PREFIX_APP_IP': '0.0.0.0'}
Fixed docstring indentation.
1.2.2 - 2024-03-10
Fixes TypeError: unsupported operand type(s) for |: 'type' and 'type'.
error when using Python version < 3.10
1.2.1 - 2024-02-04
Environment variable are now automatically set from the configuration. This makes it easier to use the configuration values in your application.
Env variables of all config keys are set as uppercase. e.g. APP_HOST
and APP_PORT
or APP_CONFIG_APP_HOST
and APP_CONFIG_APP_PORT
if env_prefix
is set to "app_config".
It will also try and convert the values to the correct type. e.g. APP_PORT
will be set as an integer if the env value is 8080
Nested values can also be accessed. ex: TABLE_KEY_LEVEL1_KEY_LEVEL2_KEY
. This works for any level of nesting.
Any existing env variables that matches will not be overwritten, but instead will overwrite the existing config value.
import os
from simple_toml_configurator import Configuration
os.environ["PROJECT_APP_PORT"] = "1111"
default = {"app": {"host": "localhost", "port": 8080}}
config = Configuration(
config_path="config_folder",
defaults=default,
config_file_name="app_settings",
env_prefix="project")
print(os.environ["PROJECT_APP_HOST"]) # Output: 'localhost'
print(os.environ["PROJECT_APP_PORT"]) # Output: '1111'
- Fixed a bug where update_config() would not update the attributes of the Configuration object.
1.1.0 - 2024-01-28
This release introduces a significant new feature: Nested Configuration Support with Attribute Access.
Nested Configuration Support with Attribute Access: In previous versions, accessing and updating nested configuration values required dictionary-style access. With this release, we've made it easier and more intuitive to work with nested configuration values. Now, you can access and update these values using attribute-style access, similar to how you would interact with properties of an object in JavaScript.
Here's an example:
# Access nested configuration values
print(settings.mysql.databases.prod) # Output: 'db1'
settings.mysql.databases.prod = 'new_value'
settings.update()
print(settings.mysql.databases.prod) # Output: 'new_value'
1.0.0 - 2023-08-27
- initial release