tox-dev / tox-ini-fmt

Formats your tox.ini files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flake8 support

gaborbernat opened this issue · comments

Add support for formatting flake8 sections.

We don't have to support all out of box 🤔 maybe a few common ones just first and iterate on it.

I gave this a shot and it kinda works, but once again there is this "comment" topic.

While #42 is about deleted comments, when parsing one of my production tox.ini files with a flake8 section I encountered the problem of inline comments. Allowed or not ( tox-dev/tox#50 ), they work for third party tools.

[flake8]
ignore =
    W504, # line break after binary operator
quiet = 1

Whereas the comment in theConfigParser._read function says inline comments get stripped, this one does not:
https://github.com/python/cpython/blob/96a60ae90c291d94c058c80351fa38b6d73eda92/Lib/configparser.py#L567

(Update -> we do not set an inline-comment-prefix and so it defaults to None)

(Pdb++) parser[section_name]
<Section: flake8>
(Pdb++) parser[section_name].items()
ItemsView(<Section: flake8>)
(Pdb++) list(parser[section_name].items())
[('ignore', '\nW504, # line break after binary operator')]

So, before going down the rabbithole and debugging ConfigParser itself...

What's your take on the whole comment story?

These nowadays should live within pyproject.toml so this will be a won't do.