fannheyward / coc-pyright

Pyright extension for coc.nvim
MIT License
1.28k stars 47 forks source link

Pyright not enabled on files that are opened with go to definition #1079

Closed ethanseow closed 4 months ago

ethanseow commented 4 months ago

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

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

Workspace: /home/ethanseow/Desktop/Projects/Redstone-Code/backend/tests
Using python from /home/ethanseow/Desktop/Projects/Redstone-Code/backend/backend-api/bin/python

[Info  - 20:07:56.926] Pyright language server 1.1.363 starting
[Info  - 20:07:56.932] Server root directory: file:///home/ethanseow/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist
[Info  - 20:07:56.933] Starting service instance "backend"
[Info  - 20:07:56.943] Setting pythonPath for service "backend": "/home/ethanseow/Desktop/Projects/Redstone-Code/backend/backend-api/bin/python"
[Info  - 20:07:56.983] Assuming Python version 3.10.12.final.0
[Info  - 20:07:57.073] Auto-excluding /home/ethanseow/Desktop/Projects/Redstone-Code/backend/backend-api
[Info  - 20:07:57.080] Found 7 source files

When I use gd to go to definition of a module in my file, Pyright does not seem to be enabled on the newly opened file

for example:

# this is fileA.py
from fileB import test
asdfsdfdas # this will have pyright highlighting indicating unassigned variable
# this is fileB.py
def test():
    pass

If I am in fileA.py, Pyright correctly determines that there is an issue with the unassigned variable, but then if I go to definition to fileB.py and add the following to the end of the file, Pyright will fail to detect the incorrect code. If I were to open fileB.py directly, Pyright works as it should

# this is fileB.py
def test():
    pass
randomCode # this will not picked up by Pyright

I am not too familiar with language servers so let me know if there is an obvious fix to this