pep8 reformatter configuration?
I seem to recall that Wing delegates reformatting to an outside executable (pep8, black, yapf, etc) , and that there's a configuration panel for the reformatters, but I can't find it. Can anyone point me in the right direction?
UPDATE:
TL;DR - can we change the autopep8
formatter to respect the new binary operator + line break recommendations: https://www.python.org/dev/peps/pep-0...
Long Version:
My organization requires code to pass a pycodestyle
check before being accepted. But Wing sometimes seems to be reformatting some bits of code like:
if (
val is None
or not val.isdigit()
or int(val) <= 0
):
to
if (
val is None or
not val.isdigit() or
int(val) <= 0
):
And then pycodestyle
complains about
./src/dashboard/utils.py:39:25: W504 line break after binary operator
The "sometimes" part is interesting. After the reformatting, pycodestyle
complains about two blocks of code. If I fix the first block, save, and check, the first block is not reformatted, and then pycodestyle
only complains about the second block. But when I fix the second block, the first block is reformatted, and pycodestyle
complains again. If I edit BOTH blocks of code and then hit save, neither one is reformatted
Now that I look into it, the docs say that
Wing uses its own copy of autopep8 for PEP 8 style formatting
And if I dig into the docs for autopep8
, it apparently depends on pycodestyle
itself!
Comments
This may be due to a version mismatch between the pycodestyle you have and the one that ships with Wing (2.5.0). Or just a bug in that or the autopep8 that we include (1.5.2). I'm going to upgrade both the copies of autopep8 and pycodestyle that Wing ships with, from version 1.5.2 to 1.6.0 for autopep8 and version 2.5.0 to 2.8.0 for pycodestyle (both the latest).
Longer term, we may want to add a way to get Wing to use your installed autopep8, as a way to avoid problems like this. Of course the installed autopep8 in your Python may also not match the version being used in precommit hooks.
I should note that I tried both with the above versions and got the same result in both cases it's but different than what you seemed ... (more)