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

last trailing comma in an envlist gets turned into three trailing whitespaces #41

Closed
jugmac00 opened this issue Oct 5, 2020 · 4 comments · Fixed by #43
Closed

last trailing comma in an envlist gets turned into three trailing whitespaces #41

jugmac00 opened this issue Oct 5, 2020 · 4 comments · Fixed by #43

Comments

@jugmac00
Copy link
Member

jugmac00 commented Oct 5, 2020

I swapped the whitespaces for numbers to make them visible.

 [tox]
 envlist =
-    py36,
-    py37,
-    py38,
-    pre-commit,
-    mypy,
+    py38
+    py37
+    py36
+    pre-commit
+    mypy
+123
@gaborbernat
Copy link
Member

Can you post a reproducible example 🤔

@jugmac00
Copy link
Member Author

jugmac00 commented Oct 5, 2020

e.g.
https://github.com/jugmac00/flask-reuploaded/blob/master/tox.ini

The problem is reproducible for me for different tox.ini files, when the last env in the envlist has a trailing comma.

I would have a look myself tomorrow as the envlist parsing seems to be related to the flake8 e.g. ignore entry.

@jugmac00 jugmac00 changed the title trailing comma gets turned into three trailing whitespaces last trailing comma in an envlist gets turned into three trailing whitespaces Oct 5, 2020
@jugmac00
Copy link
Member Author

jugmac00 commented Oct 5, 2020

Found it. I will create a PR tomorrow.

@jugmac00
Copy link
Member Author

jugmac00 commented Oct 6, 2020

With a envlist like

[tox]
envlist =
    py38,
    py39,
    pre-commit,
    mypy,

to_list_of_env_values wrongly outputs
'\npy39\npy38\npy37\npy36\npre-commit\nmypy\n'
(note the trailing newline), which results in
'[tox]\nenvlist = \n\tpy39\n\tpy38\n\tpy37\n\tpy36\n\tpre-commit\n\tmypy\n\t\n\n[pytest]\npython_classes = Test[A-Z]*\n\n'.

The tabs get replaced by 4 spaces (result = result.replace("\t", INDENTATION)) and then result = result.replace(" \n", "\n") removes one of them, leading to the at first confusing 3 spaces :-)

This only matters when there is more than one key/value pair - otherwise result = output.getvalue().strip() "fixes" the additional tabs and newlines.

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 a pull request may close this issue.

2 participants