Pyright extension for coc.nvim

Overview

coc-pyright

GitHub Sponsors Patreon donate button PayPal donate button

Pyright extension for coc.nvim

1

Install

:CocInstall coc-pyright

Note: Pyright may not work as expected if can't detect project root correctly, check #521 and Using workspaceFolders in coc.nvim.

Commands

  • python.runLinting: Run linting
  • python.sortImports: Sort imports by isort
  • pyright.version: Show the currently used Pyright version in :messages
  • pyright.organizeimports: Organize imports by Pyright
  • pyright.restartserver: This command forces the type checker to discard all of its cached type information and restart analysis. It is useful in cases where new type stubs or libraries have been installed.
  • pyright.createtypestub: Creates Type Stubs with given module name, for example :CocCommand pyright.createtypestub numpy

Configurations

These configurations are used by coc-pyright, you need to set them in your coc-settings.json.

Configuration Description Default
pyright.enable Enable coc-pyright extension true
python.analysis.autoImportCompletions Determines whether pyright offers auto-import completions true
python.analysis.autoSearchPaths Automatically add common search paths like 'src' true
python.analysis.diagnosticMode Analyzes and reports errors for open only or all files in workspace openFilesOnly
python.analysis.stubPath Path to directory containing custom type stub files typings
python.analysis.typeshedPaths Paths to look for typeshed modules []
python.analysis.diagnosticSeverityOverrides Override the severity levels for individual diagnostics {}
python.analysis.typeCheckingMode Defines the default rule set for type checking basic
python.analysis.useLibraryCodeForTypes Use library implementations to extract type information true
python.pythonPath Path to Python python
python.venvPath Path to folder with a list of Virtual Environments ""
python.formatting.provider Provider for formatting autopep8
python.formatting.blackPath Custom path to black black
python.formatting.blackArgs Arguments passed to black []
python.formatting.blackdPath Custom path to blackd blackd
python.formatting.blackdHTTPURL Custom blackd server url ""
python.formatting.blackdHTTPHeaders Custom blackd request headers {}
python.formatting.yapfPath Custom path to yapf yapf
python.formatting.yapfArgs Arguments passed to yapf []
python.formatting.autopep8Path Custom path to autopep8 autopep8
python.formatting.autopep8Args Arguments passed to autopep8 []
python.linting.enabled Whether to lint Python files true
python.linting.flake8Enabled Whether to lint with flake8 false
python.linting.banditEnabled Whether to lint with bandit false
python.linting.mypyEnabled Whether to lint with mypy false
python.linting.pytypeEnabled Whether to lint with pytype false
python.linting.pycodestyleEnabled Whether to lint with pycodestyle false
python.linting.prospectorEnabled Whether to lint with prospector false
python.linting.pydocstyleEnabled Whether to lint with pydocstyleEnabled false
python.linting.pylamaEnabled Whether to lint with pylama false
python.linting.pylintEnabled Whether to lint with pylint false
python.sortImports.path Path to isort script, default using inner version ''
python.sortImports.args Arguments passed to isort []
pyright.server Custom pyright-langserver path ''
pyright.disableCompletion Disables completion from Pyright, left other LSP features work false
pyright.disableDiagnostics Disable diagnostics from Pyright false
pyright.completion.snippetSupport Enable completion snippets support true
pyright.organizeimports.provider Organize imports provider, pyright or isort pyright

pyrightconfig.json

Pyright supports pyrightconfig.json that provide granular control over settings.

Python typing and stub files

To provide best experience, Pyright requires packages to be type annotated and/or have stub files. The Python community is currently in a transition phase where package authors are actively looking to provide that. Meanwhile, stub files for well-known packages may also be obtained from 3rd party, for example:

Conda setup

  1. Create the following file:
#!/bin/bash
python "$@"
  1. Make it executable: chmod +x $path
  2. Add the following to your coc-settings.json:
"python.pythonPath": "<PUT PATH HERE>"
  1. Activate the environment before starting vim

This way python from your currently activated environment will be used

My Workflow with Pyright

  1. create venv in project: python3 -m venv .venv
  2. source .venv/bin/activate
  3. install modules with pip and work with Pyright
  4. deactivate

License

MIT


This extension is created by create-coc-extension

Comments
  • CocCommand workspace.showOutput - coc-pyright-linting doesn't show any logs

    CocCommand workspace.showOutput - coc-pyright-linting doesn't show any logs

    My :CocConfig:

    {
        // Change all location jump, like jump to definition, in new tab.
        // From https://github.com/neoclide/coc.nvim/issues/318#issuecomment-452488348
        "coc.preferences.jumpCommand": "tab drop",
    
        // coc-pyright
        "python.linting.banditEnabled": true,
        "python.linting.flake8Enabled": true,
        "python.linting.mypyEnabled": true,
        "python.linting.pydocstyleEnabled": true,
        "python.linting.pylintEnabled": true
    }
    

    :CocCommand workspace.showOutput - coc-pyright-linting opens an empty vertical split window. It should show active linter:xxx logs.

    I have all the linters installed in my system with pipenv, and I execute pipenv shell before using neovim.

    can't reproduce 
    opened by gasull 38
  • Format on save with black isn't working

    Format on save with black isn't working

    When saving a file, [coc.nvim] Formatted with black is printed, but the file isn't changed. Running call CocAction('format') also prints the message, but the file is then updated. The output from :CocCommand workspace.showOutput is as follows:

    ########## active formattor: black
    execPath:   black
    moduleName: black
    args:       --diff,--quiet,/home/devneal/github/manim/manim/mobject/mobject.py.2c210016803c1db7200eb6ec681835ba.py
    
    ########## black output:
    --- /home/devneal/github/manim/manim/mobject/mobject.py.2c210016803c1db7200eb6ec681835ba.py	2020-12-30 05:10:36.386043 +0000
    +++ /home/devneal/github/manim/manim/mobject/mobject.py.2c210016803c1db7200eb6ec681835ba.py	2020-12-30 05:10:37.032054 +0000
    @@ -1317,8 +1317,10 @@
     
             self.method = getattr(self.mobject.generate_target(), method_name)
     
             def build(*method_args, **method_kwargs):
                 self.method(*method_args, **method_kwargs)
    -            return _MethodAnimation(self.mobject, self.method, method_args,                method_kwargs)
    +            return _MethodAnimation(
    +                self.mobject, self.method, method_args, method_kwargs
    +            )
     
             return build
    

    It seems like a temp file may be being formatted instead of the actual file, but I don't know if this is expected.

    can't reproduce 
    opened by eulertour 36
  • Issue with 'go to definition' asking me which file I want, but prompting for the same file each time.

    Issue with 'go to definition' asking me which file I want, but prompting for the same file each time.

    Hi, really love the library!

    I have a small issue, sometimes, which I try to 'go to definition' coc-pyright asks me which of the possible files hosting the defitinion I want to open. The thing is that all the prompts are to the same file! Here is an example:

    image

    And here is my config:

    {
      "python.formatting.provider": "black",
      "python.linting.pylintEnabled": true,
      "python.linting.enabled": true,
      "python.jediEnabled": false,
      "python.pythonPath": "/path/to/symlink/which/points/to/python/bin",
      "diagnostic.checkCurrentLine": true,
      "python.analysis.useLibraryCodeForTypes": false,
      "python.analysis.typeCheckingMode": "off"
    }
    

    Also when I restart vim the error gets fixed! But after using the same vim session for some time it starts happening again.

    Thanks!

    opened by joaqo 26
  • Only critical errors are now underlined

    Only critical errors are now underlined

    Issue is due to a breaking change in coc.nvim. See: https://github.com/neoclide/coc.nvim/issues/3185

    What's the output of :CocCommand pyright.version coc-pyright 1.1.154 with Pyright 1.1.154

    opened by dob9601 23
  • Rename provider not found

    Rename provider not found

    I'm having a similar issue as mentioned here: https://github.com/fannheyward/coc-pyright/issues/51#issuecomment-737721095

    Completion, diagnostics and formatting work normally.

    versions

    vim version: VIM - Vi IMproved 8.2 8022489 node version: v15.8.0 coc.nvim version: 0.0.80-8e7635b6a0 coc.nvim directory: /home/user/.vim/plugged/coc.nvim term: dumb platform: linux

    Log of coc.nvim

    CocInfo
    2021-02-25T11:05:26.404 INFO (pid:846565) [services] - registered service "diagnostic-languageserver"
    2021-02-25T11:05:26.469 INFO (pid:846565) [services] - registered service "pyright"
    2021-02-25T11:05:26.469 INFO (pid:846565) [services] - Pyright Server state change: stopped => starting
    2021-02-25T11:05:26.515 INFO (pid:846565) [plugin] - coc.nvim 0.0.80-8e7635b6a0 initialized with node: v15.8.0 after 216ms
    2021-02-25T11:05:26.523 INFO (pid:846565) [language-client-index] - pyright started with 846599
    2021-02-25T11:05:26.767 INFO (pid:846565) [services] - Pyright Server state change: starting => running
    2021-02-25T11:05:26.774 INFO (pid:846565) [services] - service pyright started
    2021-02-25T11:05:28.808 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:29.686 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:31.478 INFO (pid:846565) [attach] - receive notification: runCommand [ 'document.renameCurrentWord' ]
    2021-02-25T11:05:31.784 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:34.419 INFO (pid:846565) [attach] - receive notification: showInfo []
    
    CocOpenLog
    2021-02-25T11:05:26.404 INFO (pid:846565) [services] - registered service "diagnostic-languageserver"
    2021-02-25T11:05:26.469 INFO (pid:846565) [services] - registered service "pyright"
    2021-02-25T11:05:26.469 INFO (pid:846565) [services] - Pyright Server state change: stopped => starting
    2021-02-25T11:05:26.515 INFO (pid:846565) [plugin] - coc.nvim 0.0.80-8e7635b6a0 initialized with node: v15.8.0 after 216ms
    2021-02-25T11:05:26.523 INFO (pid:846565) [language-client-index] - pyright started with 846599
    2021-02-25T11:05:26.767 INFO (pid:846565) [services] - Pyright Server state change: starting => running
    2021-02-25T11:05:26.774 INFO (pid:846565) [services] - service pyright started
    2021-02-25T11:05:28.808 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:29.686 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:31.478 INFO (pid:846565) [attach] - receive notification: runCommand [ 'document.renameCurrentWord' ]
    2021-02-25T11:05:31.784 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:34.419 INFO (pid:846565) [attach] - receive notification: showInfo []
    2021-02-25T11:05:34.444 INFO (pid:846565) [attach] - receive request: CocAutocmd [ 'BufReadCmd', 'output', 'output:///info' ]
    2021-02-25T11:05:34.875 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:41.086 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:05:42.221 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:06:00.897 INFO (pid:846565) [attach] - receive notification: highlight []
    2021-02-25T11:06:03.514 INFO (pid:846565) [attach] - receive notification: openLog []
    
    can't reproduce 
    opened by hejops 23
  • reportMissingModuleSource using poetv + pyenv + poetry + mypy

    reportMissingModuleSource using poetv + pyenv + poetry + mypy

    I'm getting errors that I assume the plugin can't find my virtualenv created by poetry.

    Related shell configuration

    # ~/.config/fish/config.fish
    pyenv init - | source
    which python3 | read -l answer
    set -gx PYTHONPATH "$answer/site-packages" $PYTHONPATH
    set -gx PYENV_ROOT $HOME/.pyenv
    set -gx PIPENV_PYTHON "$PYENV_ROOT/shims/python"
    
    # :CocInfo
    ## versions
    vim version: VIM - Vi IMproved 8.2 8022450
    node version: v12.14.1
    coc.nvim version: 0.0.80-6e5a2aaeb5
    

    vim src/file.py

    image

    :PoetvActivate :call CocAction('reloadExtension', 'coc-pyright') I guess this is needed?

    image

    Doesn't seem to work? (Also note my statusline's backend-dmp... which denotes poetv has activated the environment)

    Packages:

    Click to expand

    :!pip list

    
    Package                   Version
    ------------------------- ------------
    aiofiles                  0.6.0
    aiohttp                   3.7.3
    async-timeout             3.0.1
    asyncio                   3.4.3
    attrs                     20.3.0
    boto3                     1.16.24
    botocore                  1.19.24
    cachetools                4.1.1
    certifi                   2020.11.8
    chardet                   3.0.4
    h11                       0.9.0
    httpcore                  0.11.1
    httptools                 0.1.1
    httpx                     0.15.4
    idna                      2.10
    jmespath                  0.10.0
    multidict                 5.0.0
    mypy                      0.800
    mypy-boto3-secretsmanager 1.17.9.0
    mypy-extensions           0.4.3
    pip                       19.2.3
    python-dateutil           2.8.1
    requests                  2.25.0
    rfc3986                   1.4.0
    s3transfer                0.3.3
    sanic                     20.9.1
    Sanic-Cors                0.10.0.post3
    Sanic-Plugins-Framework   0.9.4.post1
    sentry-sdk                0.19.4
    setuptools                41.2.0
    six                       1.15.0
    sniffio                   1.2.0
    typed-ast                 1.4.2
    typing-extensions         3.7.4.3
    ujson                     4.0.1
    urllib3                   1.26.2
    uvloop                    0.14.0
    websockets                8.1
    yarl                      1.6.3
    

    the reverse order doesn't work either: vim, :PoetvActivate, :e src/file.py.

    However, poetry shell, vim src/file.py seems to work. What could be the issue here?

    opened by Lilja 19
  • Disable hint-level diagnostics

    Disable hint-level diagnostics

    Thanks for all the great work!

    Is there any way to get rid of "hint" type diagnostics? See attached screenshot: hints

    I've tried all of these with no luck:

    # pyright: reportGeneralTypeIssues=false
    # pyright: reportUnusedVariable=false
    # pyright: off
    
    opened by patnr 19
  • Analyzing the top directory (home for example) for any reason ?

    Analyzing the top directory (home for example) for any reason ?

    I'm opening /home/pafer/Project/foo/main.py for example.

    I open neovim inside /home/pafer/Projects/foo, and I create the file. Then I save it.

    This happens:

    image

    It scans the entire /home/pafer/Projects without any reason, taking the CPU and make my computer slow.

    What's the output of :CocCommand pyright.version 1.1.154

    What's the output of :CocCommand workspace.showOutput Pyright

    Here is the output, note that my python file and PWD are not in /home/pafer/Projects but in foo subdirectory ! But the "Workspace" is considered to be the top directory ?

    Workspace: /home/pafer/Projects
    Using python from /usr/bin/python
    
    [Info  - 14:56:36] Pyright language server 1.1.154 starting
    [Info  - 14:56:36] Server root directory: /home/pafer/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
    [Info  - 14:56:36] No configuration file found.
    [Info  - 14:56:36] No pyproject.toml file found.
    [Info  - 14:56:36] Setting pythonPath for service "Projects": "/usr/bin/python"
    [Warn  - 14:56:36] stubPath /home/pafer/Projects/typings is not a valid directory.
    [Info  - 14:56:36] Assuming Python version 3.9
    [Info  - 14:56:36] Assuming Python platform Linux
    [Warn  - 14:56:36] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 14:56:36] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 14:56:36] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 14:56:36] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 14:56:36] Exception received when installing recursive file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Info  - 14:56:36] Searching for source files
    [Info  - 14:56:36] Auto-excluding /home/pafer/Projects/XXX
    
    [ A lot of my Prjects/XXX folders appears here]
    
    [Info  - 14:56:49] Found 46577 source files
    [Info  - 14:57:44] Emptying type cache to avoid heap overflow. Heap size used: 1539MB
    [Info  - 14:57:58] Emptying type cache to avoid heap overflow. Heap size used: 1694MB
    [Info  - 14:58:52] Emptying type cache to avoid heap overflow. Heap size used: 1645MB
    
    opened by metal3d 18
  • could not be resolved if use pyenv local

    could not be resolved if use pyenv local

    I use pyenv for manage virtualenv of python, but if use pyenv local(.python-version file in local dir) in coc-pyright, raise reportMissingImports error on import something. image

    pyenv shell is working. PYENV_VERSION environment variable can be accepted.

    opened by junnplus 18
  • Wrong warning

    Wrong warning "Code is unreachable"

    https://github.com/microsoft/pyright/issues/1532

    For some reason Pyright thinks this code is unreachable - this is clearly a mistake.

    from contextlib import suppress
    
    seconds = 0
    with suppress(ValueError):
        seconds = int('a')
    
    if not seconds:
        seconds = 42
    

    Then it thinks all the other code, out of scope is broken too. Which is another (maybe consecutive) misconception.

    can't reproduce 
    opened by kaldown 17
  • coc-python signatureHelp stops working

    coc-python signatureHelp stops working

    I've configured coc-pyright with:

      call coc#config('pyright', {
      \   'disableLanguageServices': v:true
      \ })
    

    Because I'm trying to use it with coc-python, but now I don't get signatureHelp from either place.

    opened by oblitum 17
  • Pyright not respecting `g:WorkspaceFolders`

    Pyright not respecting `g:WorkspaceFolders`

    What's the output of :CocCommand pyright.version coc-pyright 1.1.280 with Pyright 1.1.280

    What's the output of :CocCommand workspace.showOutput Pyright

    Workspace: /home/me/scratch/monorepo/application
    Using python from dist/export/python/virtualenvs/python-default/3.10.2/bin/python
    
    [Info  - 2:28:22 PM] Pyright language server 1.1.280 starting
    [Info  - 2:28:22 PM] Server root directory: /home/me/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
    [Info  - 2:28:22 PM] Starting service instance "application"
    [Info  - 2:28:22 PM] Starting service instance "library"
    [Info  - 2:28:22 PM] Starting service instance "service"
    [Info  - 2:28:23 PM] Starting service instance "<default>"
    [Info  - 2:28:23 PM] No configuration file found.
    [Info  - 2:28:23 PM] No pyproject.toml file found.
    [Info  - 2:28:23 PM] Setting pythonPath for service "application": "/home/me/scratch/monorepo/application/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
    [Warn  - 2:28:23 PM] stubPath /home/me/scratch/monorepo/application/typings is not a valid directory.
    [Info  - 2:28:23 PM] Unable to get Python version from interpreter
    [Info  - 2:28:23 PM] Assuming Python platform Linux
    [Info  - 2:28:23 PM] Searching for source files
    [Info  - 2:28:23 PM] Found 4 source files
    [Info  - 2:28:23 PM] No configuration file found.
    [Info  - 2:28:23 PM] No pyproject.toml file found.
    [Info  - 2:28:23 PM] Setting pythonPath for service "library": "/home/me/scratch/monorepo/library/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
    [Warn  - 2:28:23 PM] stubPath /home/me/scratch/monorepo/library/typings is not a valid directory.
    [Info  - 2:28:23 PM] Unable to get Python version from interpreter
    [Info  - 2:28:23 PM] Assuming Python platform Linux
    [Info  - 2:28:23 PM] Searching for source files
    [Info  - 2:28:23 PM] Found 4 source files
    [Info  - 2:28:23 PM] No configuration file found.
    [Info  - 2:28:23 PM] No pyproject.toml file found.
    [Info  - 2:28:23 PM] Setting pythonPath for service "service": "/home/me/scratch/monorepo/service/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
    [Warn  - 2:28:23 PM] stubPath /home/me/scratch/monorepo/service/typings is not a valid directory.
    [Info  - 2:28:23 PM] Unable to get Python version from interpreter
    [Info  - 2:28:23 PM] Assuming Python platform Linux
    [Info  - 2:28:23 PM] Searching for source files
    [Info  - 2:28:23 PM] Found 4 source files
    [Info  - 2:28:23 PM] No pyproject.toml file found.
    [Info  - 2:28:23 PM] Setting pythonPath for service "<default>": "/home/me/scratch/monorepo/application/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
    [Warn  - 2:28:23 PM] stubPath typings is not a valid directory.
    [Info  - 2:28:23 PM] Unable to get Python version from interpreter
    [Info  - 2:28:23 PM] Assuming Python platform Linux
    [Info  - 2:28:23 PM] Searching for source files
    [Info  - 2:28:23 PM] No source files found.
    

    Issue

    I'm testing a monorepo layout and I can't get pyright to understand where all the roots are.

    Details

    My repo (tree below) has three major parts: application, library, and service. Each of these is supposed to be kind of self contained with it's own tests, readme, documentation etc.

    I have a bit of vimscript that sets g:WorkspaceFolders to be ["/home/me/scratch/monorepo/application", "/home/me/scratch/monorepo/library", "/home/me/scratch/monorepo/service"]. This script runs after I set the keybindings and settings of CoC. However, as you can tell by the logs, it's not using these folders. How do I manually set the workspace folders?

    I do not want to use the root_pattern stuff for two reasons:

    1. There isn't a usable root pattern.
    2. Even if there was (like if I did a touch .root in every root folder), it doesn't acknowledge all the roots unless I have at least one file per root open.
    .
    ├── application
    │   ├── application
    │   │   ├── __init__.py
    │   │   └── main.py
    │   ├── README.md
    │   └── tests
    │       ├── __init__.py
    │       └── test_application.py
    ├── default.lock
    ├── library
    │   ├── library
    │   │   ├── __init__.py
    │   │   └── main.py
    │   ├── README.md
    │   └── tests
    │       ├── __init__.py
    │       └── test_library.py
    ├── pants
    ├── pants-plugins
    │   └── version_from_git
    │       ├── __pycache__
    │       └── register.py
    ├── pants.toml
    ├── pyproject.toml
    ├── README.md
    ├── requirements.txt
    └── service
        ├── README.md
        ├── service
        │   ├── __init__.py
        │   └── main.py
        └── tests
            ├── __init__.py
            └── test_service.py
    
    opened by cheog 2
  • Is there a way to refactor and move a variable to a new file and update imports?

    Is there a way to refactor and move a variable to a new file and update imports?

    Ex. I want to move foo to a new file a2.py and have the import in b.py auto update to use that new path. Is this possible?

    # a.py
    
    def foo():
        pass
    
    # b.py
    
    from a import foo
    
    def bar():
        return foo()
    
    opened by himat 1
  • "Import could not be resolved" for newly created local module - pyright restart needed

    What's the output of :CocCommand pyright.version [coc.nvim] coc-pyright 1.1.262 with Pyright 1.1.264

    What's the output of :CocCommand workspace.showOutput Pyright

    Workspace: /home/user/python-test
    Using python from /usr/bin/python
    Pyright language server 1.1.264 starting
    Server root directory: /home/user/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
    Starting service instance "python-test"
    Setting pythonPath for service "python-test": "/usr/bin/python"
    Loading configuration file at /home/user/python-test/pyrightconfig.json
    Assuming Python version 3.10
    Assuming Python platform Linux
    No include entries specified; assuming /home/user/python-test
    Auto-excluding **/node_modules
    Auto-excluding **/__pycache__
    Auto-excluding **/.*
    stubPath /home/user/python-test/typings is not a valid directory.
    Searching for source files
    Found 2 source files
    

    Project

    mkdir python-test
    cd python-test/
    echo '{}' > pyrightconfig.json
    
    [user@test-coc-pyright python-test]$ tree 
    .
    ├── __pycache__
    │   └── foo.cpython-310.pyc
    ├── foo.py
    ├── main.py
    └── pyrightconfig.json
    

    Test environment (vanilla Fedora 36)

    mkdir -p ~/.local/share/nvim/site/pack/coc/start
    cd ~/.local/share/nvim/site/pack/coc/start
    git clone --branch release https://github.com/neoclide/coc.nvim.git --depth=1
    node --version
    #v16.16.0
    npm --version
    #8.11.0
    :CocInstall coc-pyright
    python --version
    # Python 3.10.5
    which python
    # /usr/bin/python
    

    Error description Start nvim with some module:

    nvim main.py
    

    Create new module foo.py while nvim is opened:

    :!touch foo.py
    

    Typing inside: main.py

    import foo
    

    will trigger following error:

    [Pyright reportMissingImports] [E] Import "foo" could not be resolved ───────────────────────────────────────────────────────────────────── https://github.com/microsoft/pyright/blob/main/docs/configuration.md ───────────────────────────────────────────────────────────────────── [Pyright] [H] "foo" is not accessed

    Workaround

    • Either restart nvim completely or restart pyright via (:CocList -> services -> pyright)
      • pyright.restartserver command does not help here

    Why will be a newly created local module not recognized, until nvim or pyright is restarted? Thank you for help.

    opened by mark-henry01 4
  • Text-objects do not include last line

    Text-objects do not include last line

    What's the output of :CocCommand pyright.version

    coc-pyright 1.1.253 with Pyright 1.1.253

    What's the output of :CocCommand workspace.showOutput Pyright

    Workspace: /Users/sabah/Desktop/test Using python from /Users/sabah/Desktop/test/venv/bin/python

    [Info - 12:18:12] Pyright language server 1.1.253 starting [Info - 12:18:12] Server root directory: /Users/sabah/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/ [Info - 12:18:12] No configuration file found. [Info - 12:18:12] No pyproject.toml file found. [Info - 12:18:12] Setting pythonPath for service "test": "/Users/sabah/Desktop/test/venv/bin/python" [Warn - 12:18:12] stubPath /Users/sabah/Desktop/test/typings is not a valid directory. [Info - 12:18:12] Assuming Python version 3.7 [Info - 12:18:12] Assuming Python platform Darwin [Info - 12:18:12] Searching for source files [Info - 12:18:12] Auto-excluding /Users/sabah/Desktop/test/venv [Info - 12:18:12] Found 1 source file

    Function and Class inner text-objects do not include last line.

    Screenshot 2022-06-10 at 12 21 06

    opened by sabah-AB 2
  • Goto definition stop working after diving into python internals with virtualenvwrapper

    Goto definition stop working after diving into python internals with virtualenvwrapper

    Hello,

    I use this extension in a setup where I have pyenv to control python versions and on top of it virtualvenvwrapper to keep my venvs organized in a common folder and it works much like the anaconda scenario but with a WORKON_HOME envvar to tell were the virtualenvs are (~/.virtualenvs in my case), and a VIRTUAL_ENV envvar that once activated tells the location of the activated venv.

    I noticed that sometimes while diving into python internals definitions the goto definition stops working and keeps showing the following message:

    [coc.nvim] definition not found
    

    The only way I can get them back working is by closing vim or nvim and opening it again. It was hard to find a pattern but today I found a consistent way of reproducing it, you just need to create a folder to your code then a setup.py file with the following content:

    from setuptools import setup
    
    setup()
    

    The next steps to reproduce it are:

    • Open the file
    • Jump into setup() definition
    • Jump into _install_setup_requires(attrs) that is in the same file to see everything works
    • Then jump into setup from the line bellow _install_setup_requires that has this content return distutils.core.setup(**attrs)
    • At this point you will notice that you leave virtualenv space to reach pyenv distutils core code
    • Navigate back to your setup.py code without closing the editor
    • Jump into setup() definition
    • Jump into _install_setup_requires(attrs) and this time it's not working anymore

    Checking the outputs I got this:

    What's the output of :CocCommand pyright.version

    [coc.nvim] coc-pyright 1.1.243 with Pyright 1.1.244
    

    What's the output of :CocCommand workspace.showOutput Pyright

    Workspace: /home/humrochagf/Projects/example
    Using python from /home/humrochagf/.virtualenvs/test/bin/python
    
    [Info  - 5:16:10 PM] Pyright language server 1.1.244 starting
    [Info  - 5:16:10 PM] Server root directory: /home/humrochagf/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
    [Info  - 5:16:10 PM] No configuration file found.
    [Info  - 5:16:10 PM] No pyproject.toml file found.
    [Info  - 5:16:10 PM] Setting pythonPath for service "example": "/home/humrochagf/.virtualenvs/test/bin/python"
    [Warn  - 5:16:10 PM] stubPath /home/humrochagf/Projects/example/typings is not a valid directory.
    [Info  - 5:16:10 PM] Assuming Python version 3.10
    [Info  - 5:16:10 PM] Assuming Python platform Linux
    [Info  - 5:16:10 PM] Searching for source files
    [Info  - 5:16:10 PM] Found 1 source file
    [Info  - 5:16:15 PM] No configuration file found.
    [Info  - 5:16:15 PM] No pyproject.toml file found.
    [Info  - 5:16:15 PM] Setting pythonPath for service ".pyenv": "/home/humrochagf/.virtualenvs/test/bin/python"
    [Warn  - 5:16:15 PM] stubPath /home/humrochagf/.pyenv/typings is not a valid directory.
    [Info  - 5:16:15 PM] Assuming Python version 3.10
    [Info  - 5:16:15 PM] Assuming Python platform Linux
    [Info  - 5:16:15 PM] Searching for source files
    [Info  - 5:16:16 PM] Found 7370 source files
    [Info  - 5:17:29 PM] No pyproject.toml file found.
    [Info  - 5:17:29 PM] Setting pythonPath for service "<default>": "/home/humrochagf/.virtualenvs/test/bin/python"
    [Warn  - 5:17:29 PM] stubPath typings is not a valid directory.
    [Info  - 5:17:29 PM] Assuming Python version 3.10
    [Info  - 5:17:29 PM] Assuming Python platform Linux
    [Info  - 5:17:29 PM] Searching for source files
    [Info  - 5:17:29 PM] No source files found.
    

    I Tried to compare with the same setup of having pyenv but instead of using virtualenvwrapper creating a venv inside the code folder and in that case, everything works properly.

    And checking the logs I noticed that I don't get the Setting pythonPath for service "<default>" log chunk.

    This is my venv test for comparison:

    Workspace: /home/humrochagf/Projects/example
    Using python from /home/humrochagf/Projects/example/.venv/bin/python
    
    [Info  - 5:45:21 PM] Pyright language server 1.1.244 starting
    [Info  - 5:45:21 PM] Server root directory: /home/humrochagf/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
    [Info  - 5:45:21 PM] No configuration file found.
    [Info  - 5:45:21 PM] No pyproject.toml file found.
    [Info  - 5:45:21 PM] Setting pythonPath for service "example": "/home/humrochagf/Projects/example/.venv/bin/python"
    [Warn  - 5:45:21 PM] stubPath /home/humrochagf/Projects/example/typings is not a valid directory.
    [Info  - 5:45:21 PM] Assuming Python version 3.10
    [Info  - 5:45:21 PM] Assuming Python platform Linux
    [Info  - 5:45:21 PM] Searching for source files
    [Info  - 5:45:21 PM] Found 1 source file
    [Info  - 5:45:36 PM] No configuration file found.
    [Info  - 5:45:36 PM] No pyproject.toml file found.
    [Info  - 5:45:36 PM] Setting pythonPath for service ".pyenv": "/home/humrochagf/Projects/example/.venv/bin/python"
    [Warn  - 5:45:36 PM] stubPath /home/humrochagf/.pyenv/typings is not a valid directory.
    [Info  - 5:45:36 PM] Assuming Python version 3.10
    [Info  - 5:45:36 PM] Assuming Python platform Linux
    [Info  - 5:45:36 PM] Searching for source files
    [Info  - 5:45:37 PM] Found 7370 source files
    

    Another info that may be pertinent is that the Setting pythonPath for service "<default>" log chunk happens at the second time I jump from my code into the setup() call.

    Thanks for taking the time of reading my issue and also thanks a lot for this awesome extension :)

    opened by humrochagf 9
  • coc-pyright could not find pyrightconfig.json

    coc-pyright could not find pyrightconfig.json

    I have following project structure:

    .
    ├── src
    │  ├── app
    │  │  ├── assets
    │  │  │  └── test.js
    │  │  ├── core
    │  │  │  └── test.py
    │  │  ├── __init__.py
    │  │  ├── package-lock.json
    │  │  ├── package.json
    │  │  └── package.json
    │  └── manage.py
    ├── poetry.lock
    ├── pyproject.toml
    ├── pyrightconfig.json
    └── README.md
    

    To reproduce issue, you need to have coc-tsserver and coc-pyright installed. Clone this example and open src/app/assets/test.js, and then src/app/core/test.js https://github.com/last-partizan/coc-project-dir-issue

    Looks like coc-tsserver adds src/app to workspaceFolders, and coc-pyright uses first entry to look for pyrightconfig.json.

    Output of :CocCommand workspace.workspaceFolders

    /tmp/test-project-dir/src/app
    /tmp/test-project-dir
    

    What's the output of :CocCommand pyright.version

    [coc.nvim] coc-pyright 1.1.194 with Pyright 1.1.195
    

    What's the output of :CocCommand workspace.showOutput Pyright

    Workspace: /tmp/coc-project-dir-issue/src/app
    Using python from /usr/bin/python
    
    [Info  - 12:12:24 PM] Pyright language server 1.1.195 starting
    [Info  - 12:12:24 PM] Server root directory: /home/serg/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
    [Info  - 12:12:24 PM] No configuration file found.
    [Info  - 12:12:24 PM] No pyproject.toml file found.
    [Info  - 12:12:24 PM] Setting pythonPath for service "app": "/usr/bin/python"
    [Warn  - 12:12:24 PM] stubPath /tmp/coc-project-dir-issue/src/app/typings is not a valid directory.
    [Info  - 12:12:24 PM] Assuming Python version 3.10
    [Info  - 12:12:24 PM] Assuming Python platform Linux
    [Warn  - 12:12:24 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 12:12:24 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 12:12:24 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Info  - 12:12:24 PM] Searching for source files
    [Info  - 12:12:24 PM] Found 6 source files
    [Info  - 12:12:24 PM] Setting pythonPath for service "coc-project-dir-issue": "/usr/bin/python"
    [Info  - 12:12:24 PM] Loading configuration file at /tmp/coc-project-dir-issue/pyrightconfig.json
    [Info  - 12:12:24 PM] Assuming Python version 3.10
    [Info  - 12:12:24 PM] Assuming Python platform Linux
    [Info  - 12:12:24 PM] No include entries specified; assuming /tmp/coc-project-dir-issue
    [Info  - 12:12:24 PM] Auto-excluding **/node_modules
    [Info  - 12:12:24 PM] Auto-excluding **/__pycache__
    [Info  - 12:12:24 PM] Auto-excluding .git
    [Warn  - 12:12:24 PM] stubPath /tmp/coc-project-dir-issue/typings is not a valid directory.
    [Warn  - 12:12:24 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 12:12:24 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Warn  - 12:12:24 PM] Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    [Info  - 12:12:24 PM] Searching for source files
    [Info  - 12:12:24 PM] Found 7 source files
    
    opened by last-partizan 7
Owner
Heyward Fann
Heyward Fann
Flake8 extension for enforcing trailing commas in python

Flake8 Extension to enforce better comma placement. Usage If you are using flake8 it's as easy as: pip install flake8-commas Now you can avoid those a

Python Code Quality Authority 127 Sep 3, 2022
Flake8 extension to provide force-check option

flake8-force Flake8 extension to provide force-check option. When this option is enabled, flake8 performs all checks even if the target file cannot be

Kenichi Maehashi 9 Oct 29, 2022
Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.

i love my dog 2.8k Jan 5, 2023
Reproducible nvim completion framework benchmarks.

Nvim.Bench Reproducible nvim completion framework benchmarks. Runs inside Docker. Fair and balanced Methodology Note: for all "randomness", they are g

i love my dog 14 Nov 20, 2022
telescope.nvim is a highly extendable fuzzy finder over lists.

telescope.nvim is a highly extendable fuzzy finder over lists. Built on the latest awesome features from neovim core. Telescope is centered around modularity, allowing for easy customization.

nvim-telescope 8.4k Jan 5, 2023
This is a file deletion program that asks you for an extension of a file (.mp3, .pdf, .docx, etc.) to delete all of the files in a dir that have that extension.

FileBulk This is a file deletion program that asks you for an extension of a file (.mp3, .pdf, .docx, etc.) to delete all of the files in a dir that h

Enoc Mena 1 Jun 26, 2022
A Temporal Extension Library for PyTorch Geometric

Documentation | External Resources | Datasets PyTorch Geometric Temporal is a temporal (dynamic) extension library for PyTorch Geometric. The library

Benedek Rozemberczki 1.9k Jan 7, 2023
Little Ball of Fur - A graph sampling extension library for NetworKit and NetworkX (CIKM 2020)

Little Ball of Fur is a graph sampling extension library for Python. Please look at the Documentation, relevant Paper, Promo video and External Resour

Benedek Rozemberczki 619 Dec 14, 2022
A library of extension and helper modules for Python's data analysis and machine learning libraries.

Mlxtend (machine learning extensions) is a Python library of useful tools for the day-to-day data science tasks. Sebastian Raschka 2014-2020 Links Doc

Sebastian Raschka 4.2k Jan 2, 2023
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 30, 2022
The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity

Contents Maintainer wanted Introduction Installation Documentation License History Source code Authors Maintainer wanted I am looking for a new mainta

Antti Haapala 1.2k Dec 16, 2022
Example python package with pybind11 cpp extension

Developing C++ extension in Python using pybind11 This is a summary of the commands used in the tutorial.

null 55 Sep 4, 2022
An open source Flask extension that provides JWT support (with batteries included)!

Flask-JWT-Extended Features Flask-JWT-Extended not only adds support for using JSON Web Tokens (JWT) to Flask for protecting views, but also many help

Landon Gilbert-Bland 1.4k Jan 4, 2023
Simple extension that provides Basic, Digest and Token HTTP authentication for Flask routes

Flask-HTTPAuth Simple extension that provides Basic and Digest HTTP authentication for Flask routes. Installation The easiest way to install this is t

Miguel Grinberg 1.1k Jan 5, 2023
Simple Login - Login Extension for Flask - maintainer @cuducos

Login Extension for Flask The simplest way to add login to flask! Top Contributors Add yourself, send a PR! How it works First install it from PyPI. p

Flask Extensions 181 Jan 1, 2023
FastAPI extension that provides JWT Auth support (secure, easy to use, and lightweight)

FastAPI JWT Auth Documentation: https://indominusbyte.github.io/fastapi-jwt-auth Source Code: https://github.com/IndominusByte/fastapi-jwt-auth Featur

Nyoman Pradipta Dewantara 468 Jan 1, 2023
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 31, 2022
MongoEngine flask extension with WTF model forms support

Flask-MongoEngine Info: MongoEngine for Flask web applications. Repository: https://github.com/MongoEngine/flask-mongoengine About Flask-MongoEngine i

MongoEngine 815 Jan 3, 2023
A caching extension for Flask

Flask-Caching Adds easy cache support to Flask. This is a fork of the Flask-Cache extension. Flask-Caching also includes the cache module from werkzeu

Peter Justin 774 Jan 2, 2023