Support python type hints to improve DX

Do you support python type hints to improve the developer experience when writing custom scripts?

Currently I get no code completion in VS Code when I import various functions from prodigy.

Prodigy is pretty much fully typed with type hints so it's strange that this is not working :thinking: Is this happening for all modules? I wonder if there's a problem with the Cython compiler stripping out type hints from the compiled modules (which is something we've come across and – afaik – fixed in spaCy previously).

Ah yes I think that might be the case. It is a problem for almost all. get_schema from prodigy.components.validate works fine. The following do not

from prodigy.components.loaders import get_stream, get_loader
from prodigy.components.validate import get_schema
from prodigy.core import recipe, get_recipe, set_recipe
from prodigy.util import get_config, set_hashes, log, msg

In spaCy stub files were added.

Update

I also recall noticing an issue afterwards that Sofie took care of

Do you keep a backlog of issues/enhancements? Is it sufficient to request it here? :cowboy_hat_face:

Just checking to see if there has been any change in the status of this or some source for stub files.

I've gotten very used to having type hints not just for completion but as a form of quick documentation reference. I'm experienced with Python but new to Prodigy and this would help me get my bearings more quickly.

Welcome to the forum @sbrown :wave:

I can confirm that we have revised and fixed typing across the library a few releases back and I definitely get type hints for the functions mentioned in this thread before. At least in VSCode.
If there are any issues left it's probably due to Cython compiler. Could you share specific instances where you're not getting types so we can investigate those? Thank you!

Hi @magdaaniol, thank you so much for your help!

For me, there are no situations where either the LSP or static type checking works with Prodigy. I am using neovim on Fedora Linux. I use (Microsoft) pyright as my language server and for in-editor type checking. I also use mypy outside of my editor for type checking. None of these work at all with Prodigy.

I have no issues getting language or type information for any other Python modules, including Spacy.

Thanks again!

Hmm yeah the type hints are going missing during the Cython conversion it seems. We're looking at this, thanks!