Skip to content

Fix formatting issues with toml.dump - #18

Merged
elpekenin merged 4 commits into
elpekenin:mainfrom
relic-se:boolean-lower
Aug 27, 2026
Merged

Fix formatting issues with toml.dump#18
elpekenin merged 4 commits into
elpekenin:mainfrom
relic-se:boolean-lower

Conversation

@relic-se

@relic-se relic-se commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

I found that I would encounter issues with os.getenv and supervisor.get_setting when updating settings.toml with toml.dump. Specifically, it would expect the following:

  • Strings to be wrapped in double quotes rather than single quotes
  • Boolean values to be lowercase (ie: true and false rather than True and False)

This update changes the value formatting within toml.dumps to fix this error.

Example Code

# boot.py
import storage
storage.remount("/", False)
# code.py
import supervisor
import toml

data = {
    "teststr": "Hello world!",
    "testbool": True
}
with open("/settings.toml", "w") as f:
    toml.dump(data, f)
print((
    supervisor.get_setting("teststr"),
    supervisor.get_setting("testbool")
))
# prints "('Hello world!', True)"

@elpekenin elpekenin left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could reproduce the issues and confirm these changes fix them!

Just a couple of nitpick suggestions about the writing of the code, while keeping its behaviour

Thanks for your contribution

Comment thread toml/_toml.py Outdated
Comment thread toml/_toml.py Outdated
@relic-se

Copy link
Copy Markdown
Contributor Author

@elpekenin A-okay with your suggestions. 👍

Should be good to go now.

@elpekenin
elpekenin merged commit 19aeefc into elpekenin:main Aug 27, 2026
1 check passed
@relic-se
relic-se deleted the boolean-lower branch August 27, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants