wistful / SublimeAutoPEP8

Automatically formats Python code to conform to the PEP 8 style guide using autopep8 and pep8 modules
144 stars 23 forks source link

Walrus operator autoformatted incorrectly. #65

Closed paul-morenkov closed 3 years ago

paul-morenkov commented 4 years ago

The lines

if thing := foo.bar.baz:
    thing.method()

autoformat as:

if thing:
    = foo.bar.baz
    thing.method()

which is obviously not correct.

remisphere commented 3 years ago

The last update on this project is two years old, and the walrus operator was introduced in Python 3.8, which was only released last year. The current autopep8 version should correctly format your code, but since SublimeAutoPEP8 packages its own version of it, installing a correct version in your python environment won't work. I think the only thing to do here is to update the packaged autopep8 and pycodestyle files.

In the meantime you could directly install autopep8 in a 3.8 environment and use it outside of sublime text.

wistful commented 3 years ago

I'm afraid it won't work even after the upgrade. Auto-formatting is running by SublimeText python interpreter, which is locked to version 3.3, and walrus operator is supporter starting python3.8.