Create Stub File for Type Annotation
Using VSCode with pylance plugin in strict mode generate a lot of errors about missing type annotation. The request is to create a stub file (*.pyi) to document every type of constants, methods, functions, etc.
https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0561/
Thanks for the feature request and here some initial findings.
Using stubgen, stub drafts can be generated for Python sources: https://mypy.readthedocs.io/en/stable/stubgen.html
That covers very small of the project, implemented mainly in Cython (pyx source). There is no similar tool for Cython and stubs must be implemented manually, which requires more work however.
I added stubgen draft _exceptions.pyi and minimal pyrfc.pyi and tested with Pylance in basic mode. It works as expected (warnings are gone) but more work is needed to cover the whole project. PR is welcome here.
References:
- https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
- https://github.com/typeddjango/django-stubs