flake8 icon indicating copy to clipboard operation
flake8 copied to clipboard

Display list of available formatters with help for --format

Open asottile opened this issue 4 years ago • 10 comments

In GitLab by @blueyed on Apr 26, 2018, 03:32

flake8 --help contains:

--format=format Format errors according to the chosen formatter.

It would be nice/helpful if the list of available formats would be listed there.

asottile avatar Apr 03 '21 02:04 asottile

In GitLab by @Ruairidh on May 13, 2020, 09:01

Is this request still viable? I may have time to take a look.

asottile avatar Apr 03 '21 02:04 asottile

In GitLab by @asottile on May 13, 2020, 13:38

yep! this shouldn't be too difficult to handle -- basically you'll iterate through the available formatter plugins and add that to the help text

you can look at how the code for --version works to see how plugin collection works

asottile avatar Apr 03 '21 02:04 asottile

In GitLab by @Ruairidh on May 13, 2020, 15:00

First attempt at this here. I had to move the register_default_options call to after the plugins are registered -- not sure if that's the preferred method though.

asottile avatar Apr 03 '21 02:04 asottile

Hi @asottile Is this one still relevant and available? In case it is I would like to try to contribute :)

colens3 avatar Oct 28 '21 07:10 colens3

yep still needs doing -- @rkm might've been working on this so maybe take a look at the progress they made above

asottile avatar Oct 28 '21 14:10 asottile

I don't remember if I made any progress after this. Feel free to pick it up!

rkm avatar Oct 28 '21 15:10 rkm

Cool, tnx!

Just want to verify that I got the idea - so the idea is to update help output for --format to something like:

--format format Format errors according to the chosen formatter. Available formatters: x, y, z

Please just confirm if above is correct, also if you have any high level info on how would you approach solving this in code it would be helpful (is previous approach on right track?) :)

colens3 avatar Oct 29 '21 10:10 colens3

I don't believe so

sigmavirus24 avatar Oct 29 '21 11:10 sigmavirus24

it also needs to mention (similar to the previous attempt) that format can also take the other form with fields

asottile avatar Oct 29 '21 12:10 asottile

got it, tnx!

colens3 avatar Oct 29 '21 12:10 colens3