Open NextLight opened 3 years ago
Yes, this would be great
Intellisense/autocomplete doesnt work for me as well when working with the skia-python package on vscode .. please fix this probleme
It has been some what annoying so far having to look back and forth between the documentation/api and my code just to know what returns and what methods the skia package gives. Will there be a fix for this soon?
I tried pybind11-stubgen
and mypy's stubgen
from the issue description. I'll share some findings here even though I haven't figured out a working solution for everyone.
pybind11-stubgen skia
didn't generate stubs due to errors.
stubgen
looks more promising (https://github.com/sizmailov/pybind11-stubgen/issues/31). I was able to generate type stubs that work more or less. I ran the following in my project root directory:
pip install mypy skia
stubgen -p skia -o . # Generates stubs in `./skia`
touch skia/py.typed # https://peps.python.org/pep-0561/
sed -i '' 's/Sk//g' skia/__init__.pyi # Removes the Sk prefix
The generated skia
directory contains type stubs for skia
. It could be put anywhere in sys.path
like your project root or site-packages
.
Now I got type stubs that are somewhat useful for autocompletion and basic type check, but they still have many issues:
def
: I just commented it out...@staticmethod
and removed the first argument of the ones that I use, but this is not a scalable solution.Any
I hope this helps for someone who's willing to investigate it further.
Is your feature request related to a problem? Please describe. Intellisense/autocomplete doesn't work in Visual Studio Code when using Pylance as the language server.
It works when using Jedi or the Microsoft language server but it still has issues understanding the return types of functions.
Describe the solution you'd like This is a known "issue" with Pylance, but they say it is a design choice. The solution should be to generate type stubs as discussed in this issue.
There is a discussion on how to automatically generate stubs for pybind11 here and the options seems to be either pybind11-stubgen or mypy's stubgen.
Describe alternatives you've considered I could use a different LS such as Jedi but it's worse in general and there would still be issues.
Additional context