First time here? Check out the FAQ!
1

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 autopep8formatter 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!

Chris Curvey's avatar
216
Chris Curvey
asked 2022-01-07 06:51:32 -0500, updated 2022-01-12 09:40:38 -0500
edit flag offensive 0 remove flag close merge delete

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)

Wingware Support's avatar Wingware Support (2022-01-12 14:21:54 -0500) edit
add a comment see more comments

1 Answer

1

This is controlled from the Options tab in Project Properties or the Editor > Auto-Reformatting preferences page. The docs are at https://wingware.com/doc/edit/auto-re...

Wingware Support's avatar
4k
Wingware Support
answered 2022-01-07 07:58:15 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer