neoclide / coc-python

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

Cached values override local config #93

Open D-K-E opened 5 years ago

D-K-E commented 5 years ago

I use black and mypy for formatting and linting. I have tried to pass an argument to black to use 79 characters for lines by modifying my project's coc-settings.json.

After that I called CocRestart and closed and reopened the nvim. However somewhere along that process, I assume that the cached values corrupted the use of local settings, because I am constantly asked to install black, and select a linter, whereas my project coc-settings.json is the following:

{
    "python.linting.pylintEnabled": false,
    "python.linting.mypyEnabled": true,
    "python.linting.mypyPath": "/home/name/miniconda3/envs/dev-python/bin/mypy",
    "python.linting.enabled": true,
    "python.formatting.provider": "black",
    "python.formatting.blackPath": "/home/name/miniconda3/envs/dev-python/bin/black",
    "python.formatting.blackArgs": [
        "-l",
        "79"
    ]
}

Those are valid paths to the executable of black and mypy. I could not find how to clean cached values. The log clearly shows that cached values exist by the way: Here is the relative part from the output of CocOpenLog:

2019-09-20T04:03:39.658 INFO (pid:4577) [extension-coc-python] - Python Extension: Cached data exists getEnvironmentVariables, /media/name/Data7510/GitProjects/vie/viewer/glwidget.py
2019-09-20T04:03:39.702 INFO (pid:4577) [extension-coc-python] - Python Extension: Cached data exists getEnvironmentVariables, /media/name/Data7510/GitProjects/vie/viewer/glwidget.py
2019-09-20T04:03:41.118 INFO (pid:4577) [extension-coc-python] - Python Extension: Cached data exists getEnvironmentVariables, /media/name/Data7510/GitProjects/vie/viewer/glwidget.py
2

Here is the output of CocInfo

## versions

vim version: NVIM v0.3.2-649-g512e0ca
node version: v11.2.0
coc.nvim version: 0.0.74-3aea9c9662
term: xterm-256color
platform: linux

## Messages
[LC] Project root: /media/name/Data7510/GitProjects/ptmView
[LC] Project root: /media/name/Data7510/GitProjects/ptmView
[coc.nvim] Formatted with autopep8
## Output channel: snippets

## Output channel: Python

Starting Jedi Python language engine.

Linter 'pylint' is not installed. Please install it or select another linter".
Error: Module 'pylint' not installed.

Formatting with autopep8 failed.
You could either install the 'autopep8' formatter, turn it off or use another formatter.
Error: Module 'autopep8' not installed.
chemzqm commented 5 years ago

Looks like you have .vim/coc-settings.json in your project root.

D-K-E commented 5 years ago

Indeed I do. However cached values are overriding the settings I placed there.

5ilvers commented 5 years ago

I'm experiencing similar issue with the latest coc-python whenever i open a python file it always prompts me to select/install a linter, even though it's already set, and linter (flake8) is already installed in the current active interpreter I checked the interpreter is set correctly

Gee19 commented 5 years ago

I also cannot switch from pylint, seems it is always enabled and running CocCommand python.setLinter to flake8 does nothing.

Project root coc-settings:

{
  "python.pythonPath": "/Users/jhaine/Envs/sdelements/bin/python",
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": false,
  "python.linting.flake8Enabled": true,
  "python.linting.flake8Args": ["--ignore=E501,W601"],
  "coc.preferences.jumpCommand": "drop",
  "diagnostic.checkCurrentLine": true,
  "tsserver.npm": "/usr/local/bin/npm"
}
claytonlemons commented 5 years ago

I seem to be running into a similar situation:

Note: there are other settings in my workspace config that seem to be taking effect. Are the final settings resolved on an individual basis?

Question: is there a way to dump what coc thinks are the final resolved settings? If not, would it be worth making a feature request for this?

Gee19 commented 5 years ago

Thank you @claytonlemons, after reading your comment I went back to the docs and learned of the :CocConfig and :CocLocalConfig commands.

I recently switched to neovim and I assumed coc would still load from ~/.vim/coc-settings.json but it seems otherwise as copying it to ~/.config/nvim/coc-settings.json solved it.

But it does beg the question of why my workspace folder wasn't working 👼

5ilvers commented 5 years ago

Can confirm @claytonlemons 's workaround is working for me

chemzqm commented 5 years ago

Reproduced, "python.formatting.provider" could be wrong.

zlesnr commented 5 years ago

Where do I put the config that's referenced here? Running the CocCommand doesn't save anything, or seem to do anything for the litner.

5ilvers commented 5 years ago

@zlesnr see @Gee19 's comment

kierun commented 5 years ago

Same, or at least similar, problem here. I want to use mypy and black in a specific project, so I created this .vim/coc-settings.json file:

{
  "python.linting.pylintEnabled": false,
  "python.linting.enabled": true,
  "python.linting.mypyEnabled": true,
  "python.linting.mypyPath": "~/.cache/pypoetry/virtualenvs/usignals-py3.7/bin/mypy",
  "python.formatting.provider": "black",
  "python.formatting.blackPath": "~/.cache/pypoetry/virtualenvs/usignals-py3.7/bin/black"
}

However, I keep getting asked to install pylint as a linter.

pcoves commented 5 years ago

Hey there.

I moved my global configuration file away and I've this local configuration file :

{
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.formatting.provider": "black",
    "python.formatting.blackArgs": ["-l", "120"]
}

No original story here, coc still wants me to install pylint and does not allow me to use flake8 at the moment.

eyalk5 commented 4 years ago

There is no option to clear cache?

gabriel-viviani commented 4 years ago

Hey there.

I moved my global configuration file away and I've this local configuration file :

{
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": true,
    "python.formatting.provider": "black",
    "python.formatting.blackArgs": ["-l", "120"]
}

No original story here, coc still wants me to install pylint and does not allow me to use flake8 at the moment.

I'm no expert or coc-py dev, but if you're using an env you should set it. @claytonlemons and @Gee19 explanations works as a charm :D