Skip to content

Another settings.toml update, slightly different approach #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 14, 2023
Merged

Another settings.toml update, slightly different approach #182

merged 3 commits into from
Nov 14, 2023

Conversation

RetiredWizard
Copy link
Contributor

@RetiredWizard RetiredWizard commented Nov 3, 2023

I decided to take a stab at reworking the examples in this library to work with settings.toml and didn't notice the existing pr #179.

I took a slightly different approach as I didn't actually make any functional changes to the core library. The library currently doesn't directly access the settings.py file but uses a dictionary that is passed in and I decided it was less breaking to simply modify the examples to build the passed in dictionary from settings.toml. I also left a fallback to reading the secrets.py file in the examples because I didn't know when/if any learn guides that might reference the examples would be updated.

I considered just tossing this out, once I spotted the existing PR but since the work was already done, I figured I'd throw it out there anyway. There are advantages to modifying the library to access the secrets directly from the settings.toml environment variable, particularly with regards to simplifying the usage of library and example programs, so I'm not sure my approach makes sense.

edit: I tested most of the example programs using an Arduino Nano Connect RP2040.

@RetiredWizard
Copy link
Contributor Author

It has occurred to me that having a basic utility to create a secrets dictionary from the settings.toml environment parameters would ease the process of eliminating the secrets.py file. If such a function existed then moving to settings.toml would simply require the replacement of import secrets.py with an assignement similar to secrets = os.build_secrets(). Just a though....

@tannewt tannewt requested a review from FoamyGuy November 6, 2023 21:23
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

I do like this method of supporting settings.toml better since it eases the transition to the new way. Re-using the dictionary secrets that has been passed in is nice too because that can be utilized in the CPython + Blinka Context which can't use secrets.py directly due to naming collision with the builtin.

I do also like the idea of some conversion tool that can convert toml data into a dictionary as a means to bridge the distance between the two ways of configuration

@FoamyGuy FoamyGuy merged commit 18892f7 into adafruit:main Nov 14, 2023
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 17, 2023
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