segevfiner / cypcap

A Cython based Python binding for modern libpcap
https://pypi.org/project/cypcap/
BSD 3-Clause "New" or "Revised" License
13 stars 1 forks source link

Generate/add stubs for PEP561 and add py.typed #8

Open segevfiner opened 2 years ago

segevfiner commented 2 years ago

Need to figure out a way to extract the types from the Cython module to a *.pyi stub file and add a py.typed file. This should enable autocompletion and type checking.

This will require converting from a single file module to a package though. Not sure whether to place all code in an __init__.pyx or include an internal _cypcap.pyx and have __init__.py do a from ._cypcap import *

segevfiner commented 2 years ago

This also depends on either finding a third party way to do this or for Cython to add builtin support.

segevfiner commented 2 years ago

Apparently neither mypy nor pyright can successfully generate a draft stub file from a native Cython module 🤷‍♂️

segevfiner commented 2 years ago

It seems there is some bizarre conflict here where pylance/pyright expects typing files to include docstrings and default values, but none of the existing ones do...

FeldrinH commented 9 months ago

There seems to be some relevant progress in https://github.com/cython/cython/pull/3818 and https://github.com/cython/cython/pull/5744. I would love to see this issue resolved, because as it is right now, my IDE fails to find any type info for cypcap and considers every reference to a cypcap method or class an error.

FeldrinH commented 9 months ago

In the meantime it might also be worth checking out the existing .pyx -> .pyi converters mentioned here: https://github.com/cython/cython/pull/3818#issuecomment-1666687625