question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flake8 extensions/plugin (black, rst-docstrings, and other) entries not reported by vscode

See original GitHub issue

Environment 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:

image

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-black
  • flake8-docstrings
  • flake8-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 (ViewOutput, 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:16

github_iconTop GitHub Comments

4reactions
jraygauthiercommented, Feb 21, 2019

Alright, will try to take some time to do this.

1reaction
adam-grant-hendrycommented, May 6, 2022

@karrtikr Yes, of course. Please see #19086 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make sure vscode-python properly display linter ...
Can anyone help me setup vscode-python so that I can get all my linter entries, including those from flake8-rst-docstrings and flake8-black ?
Read more >
Linting Python in Visual Studio Code
The Python Extension Template makes it easy to integrate new Python tools into VS Code. To select a different linter, use the Python:...
Read more >
Static code analyzers - Modern Python Developer's Toolkit
VS Code will offer you this option when you open a Python file, but if it doesn't, run the Python: Select Linter command....
Read more >
VSCode: Setting line lengths in the Black Python code formatter
Definitely going to reference this very time I start a new project -- right after I re-learn that setting max line length in...
Read more >
Advanced Visual Studio Code for Python Developers
To assign a keybinding to a command that has no binding, double-click on it. If the key sequence you press is already assigned...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found