neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
574 stars 51 forks source link

Wrong pylint used by coc-python (neovim) #228

Closed fjhheras closed 4 years ago

fjhheras commented 4 years ago

When linting (using pylint) I obtain different results than when calling pylint from the command line. For example, it tells me that some expressions in numpy or tensorflow are wrong, but they work and they are not considered as errors if I run pylint on the terminal.

I am using neovim with coc-python inside a conda environment. When running CocCommand python.setInterpreter it detects the right python interpreter (the one of the conda environment).

In case if was a matter of having wrong paths, I created a .vim/coc-settings.json file with the following contents:

{
  "python.linting.pep8Path": "~/.miniconda/envs/fish/bin/pep8",
  "python.linting.pylintPath": "~/.miniconda/envs/fish/bin/pylint",
  "python.linting.pylintEnabled": true,
  "python.linting.pep8Enabled": false,
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": true
}

My CocConfig has this information:

{
    "python.linting.pep8CategorySeverity.E": "Warning",
    "python.linting.pep8CategorySeverity.W": "Information",
    "python.linting.pep8Enabled": true,
    "python.linting.flake8CategorySeverity.E": "Warning",
    "python.linting.flake8CategorySeverity.W": "Information",

}

My neovim also detects the right python executable:

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Multiple python3 executables found.  Set `g:python3_host_prog` to avoid surprises.
  - INFO: Executable: /home/numan/.miniconda/envs/fish/bin/python3
  - INFO: Other python executable: /usr/bin/python3
  - INFO: Other python executable: /bin/python3
  - INFO: Python version: 3.7.6
  - INFO: pynvim version: 0.4.1
  - OK: Latest pynvim is installed.

For completeness:

nvim --version
NVIM v0.4.3
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-xAEA75/neovim-0.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-xAEA75/neovim-0.4.3/build/config -I/build/neovim-xAEA75/neovim-0.4.3/src -I/usr/include -I/usr/include/lua5.1 -I/build/neovim-xAEA75/neovim-0.4.3/build/src/nvim/auto -I/build/neovim-xAEA75/neovim-0.4.3/build/include
Compiled by team+vim@tracker.debian.org

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"
fjhheras commented 4 years ago

Sorry, my wrong. It seems (at least now) that I have exactly the same problems when running pylint outside or inside vim.

However, it still marks perfectly good uses of tensorflow as errors, but that is a problem of either the linter or tensorflow. It is probably related to https://github.com/PyCQA/pylint/issues/3080