fannheyward / coc-pyright

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

coc-pyright does not correctly works with pygit #1109

Closed tupos closed 6 days ago

tupos commented 1 week ago

What's the output of :CocCommand pyright.version

[coc.nvim] coc-pyright 1.1.380 with Pyright 1.1.382

The problem comes from the following steps

mkdir 111
cd 111
python3 -m venv .venv
. ./.venv/bin/activate
pip install pygit2
echo $'import pygit2\n\nrepo: pygit2.Repository = pygit2.init_repository("/path")\n' > tt.py
nvim tt.py

After this we see that we get an error. However the error is wrong as the function returns the Repository. Also if we go to definition of init_repository we can see some undefined symbols.

Type "pygit2.repository.Repository | pygit2._pygit2.Repository" is not
assignable to declared type "Repository"
  Type "pygit2.repository.Repository | pygit2._pygit2.Repository" is not
assignable to type "Repository"
    "pygit2._pygit2.Repository" is not assignable to "pygit2.repository.
Repository" (Pyright reportAssignmentType)
──────────────────────────────────────────────────────────────────────────────
https://github.com/microsoft/pyright/blob/main/docs/configuration.
md#reportAssignmentType

The problem can also be reproduced with vscode if we add an empty pyrightconfig.json into the root of the project 111 folder.

cat pyrightconfig.json
{
}

After I enabled debug logs with 'python.analysis.logLevel', 'Trace' and compared the logs in vscode for both cases I could not see what is different. However with vscode if I remove the pyrightconfig.json completion works as expected.

The bug is probably within pyright itself, therefore I filled an issue there as well https://github.com/microsoft/pyright/issues/9104#issue-2554197146.

But my question is with respect what is different between vscode and coc-pyright with respect to the pyrightconfig.json. Why does pyright works differently in the case of coc-pyright and vscode?

As I would expect if I remove the pyrightconfig.json the error should go away.

tupos commented 6 days ago

Seams that it is working as expected. See the answer in the pyright repo. Thus closing.