Skip to content
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

Toml and maybe even yaml support #210

Closed
samuelcolvin opened this issue Jan 19, 2024 · 4 comments
Closed

Toml and maybe even yaml support #210

samuelcolvin opened this issue Jan 19, 2024 · 4 comments
Labels

Comments

@samuelcolvin
Copy link
Member

Screenshot_20240119-085927

Google suggestions makes me think toml parsing support would be very popular, we might as well also do yaml, it shouldn't be much more work.

We should use the builtin toml parser when possible, and have optional dependency groups.

@Smixi
Copy link
Contributor

Smixi commented Jan 20, 2024

Hello,

Learning pydantic and pydantic settings.
I'm not used to work with optionnal dependencies. I used the same mecanism in pydantic with email-validator.
If the current code is OK for you I will add TOML,
I basically copied the docs example from Jsonsource (which I added too).
The builtin tomlib is only available from python 3.11, but the project is >=3.8.

=3.11 = tomlib
<3.11 = fallback toml reader lib.

Do you have any recommandation for the tomlib you want me to use ?

Note: pyyaml seems broken on 3.12 with Cython :'(

@kjithin
Copy link
Contributor

kjithin commented Jan 20, 2024

Hello,

We should be able to create Toml & Yaml source by inheriting InitSettingsSource. Toml and Yaml parsing libraries generates a dict which the InitSettingsSource also uses to configure the source. I added the toml source for reference.

Is there any downside to inheriting from InitSettingsSource?

@Smixi
Copy link
Contributor

Smixi commented Jan 21, 2024

@kjithin I update the PR, I guess it's better to use the base class you mentionned :).

Is there a specific technique to handle module import during test, so the coverage will be happy :D ?

@hramezani
Copy link
Member

Added in #211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants