Skip to content

Setting environment variables fails if not all top level keys are tables. #4

@JulianVennen

Description

@JulianVennen
from simple_toml_configurator import Configuration

default_config = {
    'example': 'example-argument',
}

settings = Configuration(defaults=default_config, config_file_name="config")

print(settings.example)

This fails with the following error:

Traceback (most recent call last):
  File "./backup.py", line 11, in <module>
    settings = Configuration(defaults=default_config, config_file_name="config")
  File "./.venv/lib/python3.13/site-packages/simple_toml_configurator/toml_configurator.py", line 106, in __init__
    self.init_config(*args, **kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "./.venv/lib/python3.13/site-packages/simple_toml_configurator/toml_configurator.py", line 160, in init_config
    self._set_os_env()
    ~~~~~~~~~~~~~~~~^^
  File "./.venv/lib/python3.13/site-packages/simple_toml_configurator/toml_configurator.py", line 342, in _set_os_env
    for key, value in self.config[table].items():
                      ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'String' object has no attribute 'items'

The TOML file looks like this, which is valid TOML according to https://www.toml-lint.com/:

example = "example-argument"

_set_os_env expects every top-level key to be a table and fails if it is a string or anything else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions