-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
comments get deleted #42
Comments
In another project, which uses GPG encrypted ini files for secrets, I also reported deleted comments, they switched from https://pypi.org/project/ConfigUpdater/ While this approach seems ok for updating single values, this does not look like a lot of fun to implement for this project here 😱 That said, it looks like @asottile 's |
As mentioned in #34, there are some more issues with comments. What is your intention for comments? Support them? Delete them? Should |
Support them. TBD how though. |
Maybe also support (maximum one?) blank line? commands =
- # Unit tests
{envpython} -m pytest --cov tinytext --cov tests --cov-report xml {posargs}
-
- # Test runs
tinytext --version
tinytext --help
tinytext abcdef |
This will be pretty interesting! @gaborbernat maybe this is something for your next Twitch stream? I'd like to know your thoughts about the alternative ways to handle this. Some random thoughts... Imho, this problem breaks down into several smaller problems:
I played a bit with a config like ...
will result in...
Pretty nice! Buuut, it breaks with @hugovk's https://github.com/hugovk/tinytext/blob/master/tox.ini
Looks like Which brings me back to the good ole But there is a workaround. When initializing ConfigParser, we could pass in an arbitrary comment-prefix - like "//" - then real comments, starting with e.g.
Another problem comments before the first section
When we fake the
If comments before the first section need to be supported, that could mean e.g. that we need to read the file with e.g. |
This is promising. Can play around with something like this on my next stream. Thanks a ton for the in-depth research. |
Here's another example. First bit the same as before, second bit slightly different: --- tox.ini
+++ tox.ini
@@ -10,10 +10,7 @@
pandas
tests
commands =
- # Unit tests
{envpython} -m pytest --cov pypistats --cov tests --cov-report xml {posargs}
-
- # Test runs
pypistats --version
pypistats --help
pypistats recent --help
@@ -34,6 +31,5 @@
{envpython} -m pip install -r requirements.txt
[testenv:py39]
-# NumPy and pandas' dependency Cython doesn't yet support Python 3.9
extras =
tests https://github.com/hugovk/pypistats/blob/master/tox.ini |
I was extremely happy to find this formatter until I observed that comments gets stripped, this being a deal breaker for most projects. I even doubt that I know a project without comments inside tox.ini, some of them extremely valuable. I really hope someone comes with a solution for this. |
I personally don't have comments in any of my projects, but that's probably just me. That being said PR's are very welcome to address this shortcoming 👍 |
I bet you don't need comments because you know tox better than anyone else. Still, for bigger teams we often find the need to explain why we decided to use a specific option, so we avoid having someone else undo it by mistake. One recent example that I remember is using the trick of disabling tox install and use I wish I would have the time to do a PR on this but I am afraid that is not easy to implement or to find some free cycles. BTW, thanks again for pointing me to this project. |
One workaround
Edit: this does not work as it breaks flake8 in this case, as comments must be on their own line as per configparser specification. |
Considering the age of this issue and the very limited time of all involved, I believe that is unlikely to be ever fixed, especially as we are more likely to switch config to I searched for other generic ini formatters but none is usable. The prettier plugin for ini files is far worse as it crashes on list entries from |
I noticed tox-dev/tox-ini-fmt#42, which makes it hard to use comments in tox.ini. Auto-formatting tox.ini was the main motivation to use a separate tox.ini at all, so just keep everything in pyproject.toml. Maybe tox will eventually have first-party support for pyproject.toml; this will make the transition that much simpler.
I noticed tox-dev/tox-ini-fmt#42, which makes it hard to use comments in tox.ini. Auto-formatting tox.ini was the main motivation to use a separate tox.ini at all, so just keep everything in pyproject.toml. Maybe tox will eventually have first-party support for pyproject.toml; this will make the transition that much simpler. It appears that tox==3.21.4 (appears on on ubuntu-22.04) can't actually parse the legacy_tox_ini option, and so does not get to the point of provisioning a tox environment for the approrpiate version. We now do proper provisioning ourselves in github ci.
and
whereas the first "bug" is pretty nice, as pytest 6.0 got released already some time ago :-)
The text was updated successfully, but these errors were encountered: