-
Notifications
You must be signed in to change notification settings - Fork 210
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 Configuration (take 2) #983
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Mar 19, 2023
Closed
ryneeverett
force-pushed
the
toml2
branch
4 times, most recently
from
April 10, 2023 03:59
13278c2
to
5f6781c
Compare
This removes the last of the periods from our option names. This will not work with toml because periods are interpreted as nested options in toml. That is to say: >>> import tomllib >>> tomllib.loads('log.level = "DEBUG"') {'log': {'level': 'DEBUG'}}
Now that configurations are dictionaries, we can construct them declaratively.
Add tomli as a backport of the standard library's new tomllib. By the way, it's not just a convention to use the `.toml` extension, it's actually part of the v1.0.0 spec: > TOML files should use the extension `.toml`. So we don't need to do any additional logic to determine whether a file is ini or toml -- if it doesn't have the right extension it literally isn't toml!
Add pytest-subtests plugin to test dependencies so that pytest will show the parameters when a subTest fails. Replace methods that check against specific combinations. It would be a lot simpler to use pytest.mark.parametrize, which would eliminate the need for pytest-subtests as well as the manual setUp/tearDown, but that feature is unavailable for classes inheriting from TestCase. Converting every class that inherits from ConfigTest to pytest assertions would be too much extra noise to add to this branch, which already has a large diff. I'm also not sure it's worth the effort since it seems like it will take a couple more decades for python to standardize a testing API. ("setup.py is deprecated; use pyproject.toml and pick one of the 5 incompatible formats; use pytest as a test runner; but unittest is in the standard library with a partially incompatible API...")
Add a new subcommand to automatically convert bugwarriorrc to bugwarrior.toml. This commit adds the ini2toml package as a dependency and implements a custom profile to handle the idiosyncrasies of our bugwarriorrc format. The only "bug" I've noticed so far with ini2toml is that empty lines are not preserved. This is the standard behavior of ini2toml due to the `normalise_newlines` postprocessor, which removes all empty lines and adds one before each section. However, this seems to be due to the issue that upstream tomlkit adds lots of arbitrary empty lines (aka `Whitespace()` and leaving them all would be an even worse result. See python-poetry/tomlkit#48. This is about as far as I care to chase this bug down the rabbit hole at the moment.
ryneeverett
force-pushed
the
toml2
branch
3 times, most recently
from
July 17, 2023 04:02
d7cd743
to
50227b3
Compare
- Add sphinx-inline-tabs as a development dependency. - Create a "config" directive for configuration blocks, which converts an ini code block into tabs with both configuration languages.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on #984.This is a more conservative rewrite of #973 which aims to provide first-class support for both ini and toml configuration.
The biggest user impact is probably documentation, which now includes tabbed code blocks showing both ini and toml format. It can be viewed here: https://bugwarrior-docs.readthedocs.io/en/toml2/index.html. (Note: If I make changes to this branch I have to push separately to this remote to keep this rendering up to date.)