microsoft / vscode-flake8

Linting support for python using the flake8 library.
https://marketplace.visualstudio.com/items?itemName=ms-python.flake8
MIT License
41 stars 30 forks source link

Python 3.12.0 raises incorrect E231 in fstring #233

Closed eXhumer closed 1 year ago

eXhumer commented 1 year ago

I have made a 3.11.6 & 3.12.0 venv's and installed flake8 on both with pip install --upgrade flake8. I then added a fstring with : in a script, VSCode incorrectly reports E231 (missing whitespace after ':') in the 3.12.0 environment, while no such error is reported on 3.11.6.

image

This is a vscode-flake8 and not a flake8 issue as there is no E231 reported by flake8 command.

karthiknadig commented 1 year ago

@eXhumer Can you share the version of flake8 you have in each of the environments? Also, can you share the logs from Output > flake8.

In the logs it should show which version of flake8 is loaded and is being used. The extension itself does not generate any error codes. The only issue that I think here is that the extension is using the bundled version of flake8.

Please be careful when using pip command directly, it may not install it where you expect it to: https://snarky.ca/why-you-should-use-python-m-pip/?web=1

eXhumer commented 1 year ago

I have flake8==6.1.0 installed in both environments.

image

Output Log for Flake8 from 3.12.0 environment: https://gist.github.com/eXhumer/b7d711d3b3cdd8ba2e3c42fc6dc06f77 Output Log for Flake8 from 3.11.6 environment: https://gist.github.com/eXhumer/5f98f90bef132371997cb77ed8090eff

karthiknadig commented 1 year ago

@eXhumer From the logs it is picking up flake8==5.0.4. Set flake8.importStrategy to fromEnvironment to use flake8 from your environment.

eXhumer commented 1 year ago

That has fixed the issue for me, thanks. I hunted down the specific bug and this appears to be the problem. A permanent fix seems to be to upgrade bundled flake8 to 6.1.0 where pycodestyle gets updated to 2.11.0, which includes the above mentioned PR.

Should I close this issue or keep it open till the bundled flake8 is updated?

karthiknadig commented 1 year ago

Close it. For your needs you should have it set to fromEnvironment. We will be makeing a release soon-ish with 3.12 package updates.