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

For future major releases, consider TOML over ConfigObj for pgclirc #1162

Closed
clbarnes opened this issue Mar 27, 2020 · 5 comments
Closed

For future major releases, consider TOML over ConfigObj for pgclirc #1162

clbarnes opened this issue Mar 27, 2020 · 5 comments

Comments

@clbarnes
Copy link
Contributor

clbarnes commented Mar 27, 2020

ConfigObj fixes a lot of problems with INI, which isn't a real format, but AFAIK is a dead end in terms of adoption and indeed wider recognition as it's just one library with its own specification.

TOML resolves many of the same problems as ConfigObj and is seeing pretty widespread adoption (e.g. by the rust ecosystem, and indeed by modern python standards). Therefore it has better tooling available for it, is more recognisable, and is in wider use.

Changing config format is obviously a seriously breaking change. If there is interest in this transition, we could move to supporting both immediately, give a couple of minor versions' (Pending)DeprecationWarning, then actually deprecate it with a major version.

@clbarnes clbarnes changed the title For future major releases, consider TOML over ConfigObj For future major releases, consider TOML over ConfigObj for pgclirc Mar 27, 2020
@amjith
Copy link
Member

amjith commented Mar 27, 2020

The last time I checked the TOML library for python it didn't have a way to preserve the comments in the file when we update it.

For instance, we write to the config file when someone saves a named query. By using ConfigObj it allows us to preserve the comments in the file that a user might have added. With TOML if we read the config and write back the file it strips out the comments. I had filed an issue with the library author a while back, I don't think it has seen any movement though.

@clbarnes
Copy link
Contributor Author

Good point! The tomlkit library, from the creator of poetry, allows you to persist comments, as well as whitespace/ formatting. It's a little less transparent in its usage than the toml library is, though.

@ghost
Copy link

ghost commented Dec 1, 2020

For instance, we write to the config file when someone saves a named query. By using ConfigObj it allows us to preserve the comments in the file that a user might have added. ...

Sorry to somewhat hijack this issue, but it's the only relevant thing I found while searching for comment preserving in the config file. Are user comments supposed to be preserved already, or is it something that's possible ("allows us to ...") but not yet supported by pgcli? For me this has never worked. Just did a quick test again (pgcli 3.0.0, configobj 5.0.6, Python 3.6, Linux) by saving a named query and any manually added comments in my config file still get lost (tested the "named queries", "alias_dsn", "main" and "data_formats" sections).

If they're supposed to be preserved already I'll create a separate issue for it but first wanted to check if I understood correctly.

@j-bennet
Copy link
Contributor

j-bennet commented Dec 7, 2020

@sevens-ef Indeed, comments in pgclirc are supposed to be preserved already. If this does not work for you, please create an issue to track the problem.

@ghost
Copy link

ghost commented Feb 4, 2021

Ok, thanks! I've been busy with other things but finally got around to it...

@j-bennet j-bennet closed this as completed Dec 4, 2024
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

No branches or pull requests

3 participants