Flake8 extensions/plugin (black, rst-docstrings, and other) entries not reported by vscode
See original GitHub issueEnvironment data
- VS Code version: 1.26.1
- Extension version (available under the Extensions sidebar): 2018.7.0
- OS and version: nixos 18.03.git.ccea532 (Impala)
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.6
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): nix
- Relevant/affected Python packages and their versions: None
Expected behaviour
Given the following mymodule.py file:
from collections import \
namedtuple, \
deque
class ControlAlgoCoreSimpleSlots:
"""My non pydocstring compliant
summary which should make `flake8-docstrings` bark.
Here's some markdown code block (non valid sphinx syntax
which should make `flake8-rst-docstrings` bark.
```
def my_blocking_closure_fn():
return long_blocking_call_on(my_argument_data)
return self.make_blocking_job(my_blocking_closure_fn)
```
"""
pass
which when linted with flake8 and its plugins (see below for details) gives:
$ flake8 '--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s' ./mymodule.py
1,1,F,F401:'collections.namedtuple' imported but unused
1,1,F,F401:'collections.deque' imported but unused
1,1,D,D100:Missing docstring in public module
1,25,B,BLK100:Black would make changes.
5,1,E,E302:expected 2 blank lines, found 1
6,1,D,D204:1 blank line required after class docstring
6,1,D,D205:1 blank line required between summary line and description
6,1,D,D400:First line should end with a period
12,1,R,RST299:Inline literal start-string without end-string.
14,1,R,RST301:Unexpected indentation.
15,1,R,RST201:Block quote ends without a blank line; unexpected unindent.
15,1,R,RST299:Inline literal start-string without end-string.
15,1,R,RST299:Inline interpreted text or phrase reference start-string without end-string.
I would expect to get the same list of issue in vscode.
Note that the format string used is the same as the one used by vscode-python/src/client/linters/flake8.ts to run flake8.
Actual behaviour
Instead, I get:

See that none of the BLK entries from the flake8-black plugin are present, nor any RST entries from the flake8-rst-docstrings plugin. However, the D entries from the flake8-docstrings are properly reported.
The problem is with code prefix of more than a single alphabetical character.
Steps to reproduce:
Make sure you launch vscode in an environement with flake8 installed and the following flake8 plugins:
flake8-blackflake8-docstringsflake8-rst-docstrings
Make sure vscode has flake8 linter active and global linting:
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "flake8",
Launch Python: Run Linting on the provided mymodule.py module. Look at the Problems listing in vscode.
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
##########Linting Output - flake8##########
1,1,F,F401:'collections.namedtuple' imported but unused
1,1,F,F401:'collections.deque' imported but unused
1,1,D,D100:Missing docstring in public module
1,25,B,BLK100:Black would make changes.
5,1,E,E302:expected 2 blank lines, found 1
6,1,D,D204:1 blank line required after class docstring
6,1,D,D205:1 blank line required between summary line and description
6,1,D,D400:First line should end with a period
12,1,R,RST299:Inline literal start-string without end-string.
14,1,R,RST301:Unexpected indentation.
15,1,R,RST201:Block quote ends without a blank line; unexpected unindent.
15,1,R,RST299:Inline literal start-string without end-string.
15,1,R,RST299:Inline interpreted text or phrase reference start-string without end-string.
Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)
Console is empty after performing the linting action. I’m not sure about this source map thing however:
Suggested fix
In vscode-python/src/client/linters/baseLinter.ts, change REGEX from:
const REGEX = '(?<line>\\d+),(?<column>-?\\d+),(?<type>\\w+),(?<code>\\w\\d+):(?<message>.*)\\r?(\\n|$)';
which matches only codes with a single alphabetic character
to
const REGEX = '(?<line>\\d+),(?<column>-?\\d+),(?<type>\\w+),(?<code>\\w+\\d+):(?<message>.*)\\r?(\\n|$)';
which should now match codes with more that a single alphabetic character.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:16

Top Related StackOverflow Question
Alright, will try to take some time to do this.
@karrtikr Yes, of course. Please see #19086 .