Wemake-python-styleguide: Integration problems with VSCode

Created on 4 Nov 2019  路  14Comments  路  Source: wemake-services/wemake-python-styleguide

Bug report

What's wrong

When a run the command flake8 . is everything okay but when I want to see the errors inside of VSCode I can't see anything.

How is that should be

Show the errors in VSCode.

System information

flake8 information

Contents of flake8 --bug-report:

Traceback (most recent call last):
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/bin/flake8", line 11, in <module>
    sys.exit(main())
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/main/cli.py", line 18, in main
    app.run(argv)
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/main/application.py", line 393, in run
    self._run(argv)
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/main/application.py", line 380, in _run
    self.initialize(argv)
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/main/application.py", line 365, in initialize
    self.parse_configuration_and_cli(argv)
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/main/application.py", line 218, in parse_configuration_and_cli
    self.option_manager, self.config_finder, argv
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/options/aggregator.py", line 36, in aggregate_options
    original_values, _ = manager.parse_args(arglist)
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/options/manager.py", line 313, in parse_args
    options, xargs = self.parser.parse_args(args, values)
  File "/usr/lib/python3.7/optparse.py", line 1387, in parse_args
    stop = self._process_args(largs, rargs, values)
  File "/usr/lib/python3.7/optparse.py", line 1427, in _process_args
    self._process_long_opt(rargs, values)
  File "/usr/lib/python3.7/optparse.py", line 1501, in _process_long_opt
    option.process(opt, value, values, self)
  File "/usr/lib/python3.7/optparse.py", line 785, in process
    self.action, self.dest, opt, value, values, parser)
  File "/usr/lib/python3.7/optparse.py", line 805, in take_action
    self.callback(self, opt, value, parser, *args, **kwargs)
  File "/home/alexis/Documents/Development/Fondeadora/python-service-template/env/lib/python3.7/site-packages/flake8/main/debug.py", line 37, in print_information
    print(json.dumps(information(option_manager), indent=2, sort_keys=True))
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.7/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.7/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type cached_property is not JSON serializable

pip information

Contents of pip freeze:

aspy.yaml==1.3.0
astor==0.8.0
astroid==2.3.2
atomicwrites==1.3.0
attrs==19.3.0
autopep8==1.4.4
bandit==1.6.2
boto3==1.9.86
botocore==1.12.253
cached-property==1.5.1
cfgv==2.0.1
colorama==0.3.9
docutils==0.15.2
entrypoints==0.3
eradicate==1.0
flake8==3.7.9
flake8-annotations-complexity==0.0.2
flake8-bandit==2.1.2
flake8-broken-line==0.1.1
flake8-bugbear==19.8.0
flake8-builtins==1.4.1
flake8-coding==1.3.2
flake8-commas==2.0.0
flake8-comprehensions==2.3.0
flake8-debugger==3.2.0
flake8-docstrings==1.5.0
flake8-eradicate==0.2.3
flake8-executable==2.0.3
flake8-isort==2.7.0
flake8-logging-format==0.6.0
flake8-pep3101==1.2.1
flake8-polyfill==1.0.2
flake8-print==3.1.1
flake8-quotes==2.1.0
flake8-rst-docstrings==0.0.11
flake8-string-format==0.2.3
flakehell==0.3.0
gitdb2==2.0.6
GitPython==3.0.4
identify==1.4.7
importlib-metadata==0.23
isort==4.3.21
jmespath==0.9.4
lazy-object-proxy==1.4.3
mando==0.6.4
mccabe==0.6.1
more-itertools==7.2.0
mypy==0.740
mypy-extensions==0.4.3
nodeenv==1.3.3
packaging==19.2
pbr==5.4.3
pep8==1.7.1
pep8-naming==0.8.2
pkg-resources==0.0.0
pluggy==0.13.0
pre-commit==1.20.0
py==1.8.0
pycodestyle==2.5.0
pydocstyle==4.0.1
pyflakes==2.1.1
Pygments==2.4.2
pylint==2.4.3
pyparsing==2.4.2
pytest==5.2.2
python-dateutil==2.8.0
PyYAML==5.1.2
radon==2.4.0
restructuredtext-lint==1.3.0
s3transfer==0.1.13
six==1.12.0
smmap2==2.0.5
snowballstemmer==2.0.0
stevedore==1.31.0
termcolor==1.1.0
testfixtures==6.10.0
toml==0.10.0
typed-ast==1.4.0
typing-extensions==3.7.4.1
urllib3==1.25.6
virtualenv==16.7.7
wcwidth==0.1.7
wemake-python-styleguide==0.12.5
wrapt==1.11.2
zipp==0.6.0

.vscode/settings.json

{
  "python.pythonPath": "env/bin/python3.7",
  "python.linting.pylintEnabled": false,
  "python.linting.flake8Enabled": true,
  "python.formatting.provider": "autopep8"
}
bug dependencies help wanted starter

Most helpful comment

Hi, thanks a lot for the report! It seems like a flake8/vscode issue. I am going to open this issue in the upstream repo. And report back.

All 14 comments

Hi, thanks a lot for the report! It seems like a flake8/vscode issue. I am going to open this issue in the upstream repo. And report back.

Done! Here's the issue in the upstream: https://gitlab.com/pycqa/flake8/issues/593

@sobolevn Thanks, I saw the related issues so I will upgrade my dependencies to latest version as it recommended in adamchainz/flake8-comprehensions#193 and try again

Or do you need to make changes?

Nope, let's start from this solution. In case it works, can you please send us a pr with the fix?

@sobolevn The problem persists, I can't see the errors in VSCode, but now I can see the result of the command flake8 --bug-report

I only updated the following information:

  • flake8 information
  • pip information

System Information

flake8 information

Contents of flake8 --bug-report:

{
  "dependencies": [
    {
      "dependency": "entrypoints",
      "version": "0.3"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.7.3",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "flake8-annotations-complexity",
      "version": "0.0.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-bandit",
      "version": "2.1.2"
    },
    {
      "is_local": false,
      "plugin": "flake8-broken-line",
      "version": "0.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-bugbear",
      "version": "19.8.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-comprehensions",
      "version": "3.0.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-debugger",
      "version": "3.1.0"
    },
    {
      "is_local": false,
      "plugin": "flake8-docstrings",
      "version": "1.5.0, pydocstyle: 4.0.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-eradicate",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-executable",
      "version": "2.0.3"
    },
    {
      "is_local": false,
      "plugin": "flake8-print",
      "version": "3.1.1"
    },
    {
      "is_local": false,
      "plugin": "flake8-string-format",
      "version": "0.2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_builtins",
      "version": "1.4.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_coding",
      "version": "1.3.2"
    },
    {
      "is_local": false,
      "plugin": "flake8_commas",
      "version": "2.0.0"
    },
    {
      "is_local": false,
      "plugin": "flake8_isort",
      "version": "2.3"
    },
    {
      "is_local": false,
      "plugin": "flake8_pep3101",
      "version": "1.2.1"
    },
    {
      "is_local": false,
      "plugin": "flake8_quotes",
      "version": "2.1.0"
    },
    {
      "is_local": false,
      "plugin": "logging-format",
      "version": "0.6.0"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "naming",
      "version": "0.8.2"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.5.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.1.1"
    },
    {
      "is_local": false,
      "plugin": "pylint",
      "version": "2.4.3"
    },
    {
      "is_local": false,
      "plugin": "radon",
      "version": "2.4.0"
    },
    {
      "is_local": false,
      "plugin": "rst-docstrings",
      "version": "0.0.11"
    },
    {
      "is_local": false,
      "plugin": "wemake-python-styleguide",
      "version": "0.12.5"
    }
  ],
  "version": "3.7.9"
}

pip information

Contents of pip freeze:

Note: I updated the version of the flake8-comprehensions to 3.0.1 as is recommended in adamchainz/flake8-comprehensions#193

aspy.yaml==1.3.0
astor==0.8.0
astroid==2.3.2
atomicwrites==1.3.0
attrs==19.3.0
autopep8==1.4.4
bandit==1.6.2
boto3==1.9.86
botocore==1.12.253
cached-property==1.5.1
cfgv==2.0.1
colorama==0.3.9
docutils==0.15.2
entrypoints==0.3
eradicate==1.0
flake8==3.7.9
flake8-annotations-complexity==0.0.2
flake8-bandit==2.1.2
flake8-broken-line==0.1.1
flake8-bugbear==19.8.0
flake8-builtins==1.4.1
flake8-coding==1.3.2
flake8-commas==2.0.0
flake8-comprehensions==3.0.1
flake8-debugger==3.2.0
flake8-docstrings==1.5.0
flake8-eradicate==0.2.3
flake8-executable==2.0.3
flake8-isort==2.7.0
flake8-logging-format==0.6.0
flake8-pep3101==1.2.1
flake8-polyfill==1.0.2
flake8-print==3.1.1
flake8-quotes==2.1.0
flake8-rst-docstrings==0.0.11
flake8-string-format==0.2.3
flakehell==0.3.0
gitdb2==2.0.6
GitPython==3.0.4
identify==1.4.7
importlib-metadata==0.23
isort==4.3.21
jmespath==0.9.4
lazy-object-proxy==1.4.3
mando==0.6.4
mccabe==0.6.1
more-itertools==7.2.0
mypy==0.740
mypy-extensions==0.4.3
nodeenv==1.3.3
packaging==19.2
pbr==5.4.3
pep8==1.7.1
pep8-naming==0.8.2
pkg-resources==0.0.0
pluggy==0.13.0
pre-commit==1.20.0
py==1.8.0
pycodestyle==2.5.0
pydocstyle==4.0.1
pyflakes==2.1.1
Pygments==2.4.2
pylint==2.4.3
pyparsing==2.4.2
pytest==5.2.2
python-dateutil==2.8.0
PyYAML==5.1.2
radon==2.4.0
restructuredtext-lint==1.3.0
s3transfer==0.1.13
six==1.12.0
smmap2==2.0.5
snowballstemmer==2.0.0
stevedore==1.31.0
termcolor==1.1.0
testfixtures==6.10.0
toml==0.10.0
typed-ast==1.4.0
typing-extensions==3.7.4.1
urllib3==1.25.6
virtualenv==16.7.7
wcwidth==0.1.7
wemake-python-styleguide==0.12.5
wrapt==1.11.2
zipp==0.6.0

If you just run flake8 . does it work? Does it show the error messages?

Do you have a flake8 config? Could you show it, please?

@orsinium Sure

flake8 . Output

./src/__init__.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./src/__init__.py:1:1: D104 Missing docstring in public package
./src/models.py:0:1: WPS411 Found empty module
./src/models.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./src/models.py:1:1: D100 Missing docstring in public module
./src/handlers/__init__.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./src/handlers/__init__.py:1:1: D104 Missing docstring in public package
./src/handlers/handler.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./src/handlers/handler.py:1:1: D100 Missing docstring in public module
./src/handlers/handler.py:1:1: C101 Coding magic comment not found
./src/handlers/handler.py:5:1: D103 Missing docstring in public function
./src/handlers/handler.py:5:11: WPS221 Found line with high Jones Complexity: 17
./src/handlers/handler.py:5:34: W0613 Unused argument 'context'
./src/handlers/handler.py:7:9: Q000 Remove bad quotes
./src/handlers/handler.py:7:20: Q000 Remove bad quotes
./src/handlers/handler.py:8:9: Q000 Remove bad quotes
./src/handlers/handler.py:11:17: Q000 Remove bad quotes
./src/handlers/handler.py:11:36: Q000 Remove bad quotes
./src/handlers/handler.py:13:5: WPS331 Found local variable that are only used in `return` statements
./test/__init__.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./test/__init__.py:1:1: D104 Missing docstring in public package
./test/handlers/__init__.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./test/handlers/__init__.py:1:1: D104 Missing docstring in public package
./test/handlers/test_handler.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./test/handlers/test_handler.py:1:1: D100 Missing docstring in public module
./test/handlers/test_handler.py:1:1: C101 Coding magic comment not found
./test/handlers/test_handler.py:5:1: D103 Missing docstring in public function
./test/handlers/test_handler.py:8:1: S101 Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
./test/handlers/test_handler.py:8:21: Q000 Remove bad quotes
./test/handlers/test_handler.py:8:38: WPS432 Found magic number: 200

Flake8 Config

setup.cfg

[flake8]
# Formar only .py files
exclude=
    env
filename=*.py
# Format with autopep8
format=default
# Rules
max-line-length=88

I am pretty sure that this is a vscode / plugin / configuration issue.

It does work for me with no problems.

I only installed the Python extension and I run the linter in every save.

I also have other projects with Flake8 or Pylama and them works fine :disappointed:

Does raw flake8 (without any plugins) work for you?

Ok, let's mark it as resolved. Feel free to reopen.

Was this page helpful?
0 / 5 - 0 ratings