flake8 only linting partial file in VS Code

971 Views Asked by At

I've successfully setup flake8 in my python project (with a .flake8 file in the root), and tied it to VS Code by way of a .vscode/settings.json file so that I see linter warnings in the file that I'm cleaning up. However, at line 1000, the linter support suddenly disappears. All lines following line 1000 do not provide linter feedback.

When I run flake8 /path/to/file from the command line, I get the full list of errors and their corresponding line numbers (including a number of warnings beyond line 1000), but for some reason VS Code seems to be unable to report these errors in-line in the IDE.

Is there some configuration I'm missing to allow VS Code to lint the rest of my large files beyond line 1000?

1

There are 1 best solutions below

0
On BEST ANSWER

After further testing, I found the issue. I was using black and flake8 in the settings.json file for vscode, and apparently, black was hitting a syntax error that I had introduced higher up in the file (around line 1000). This caused a silent failure of the linter sequence that VS code is running to present the "error squiggly lines".

When running a pre-commit hook (pre-commit run -a) that runs all 3 linters (black, iSort, and flake8), the syntax error was reported by black and easily fixed, but when run "on save" in VS-code, it fails silently and stops reporting inline errors in the IDE.

With the syntax error fixed, running flake8 from the command line returns the expected number of warnings/errors, and VS Code again shows the squiggly lines on errors, for the full file, regardless of length.