cuQuantum icon indicating copy to clipboard operation
cuQuantum copied to clipboard

[Feature Request] Python type annotation

Open EarlMilktea opened this issue 1 year ago • 4 comments

Are there any plans for adding type hints to the Python bindings? (If not, I'm willing to submit a PR :smile: )

EarlMilktea avatar Aug 21 '24 22:08 EarlMilktea

Currently our library is not set up to accept PR from github but we appreciate your feedback. I will create an internal ticket to keep track of this feature request.

yangcal avatar Aug 22 '24 00:08 yangcal

Hi @EarlMilktea, could you be more explicitly on which APIs you need for type hints? Note that the low-level bindings are auto-generated Cython code (we do not modify them manually) and already use Cython static typing (instead of the Pure Python Mode). Cython's .pxd/.pyx files aren't really fully compatible with PEP-484 type hints. For example, cython/cython#4756 is one relevant issue.

For high-level pythonic APIs I agree type hints can be valuable, though some of the functions are hard to annotate (ex: contract accepts multiple array types, making typing impossible).

leofang avatar Aug 26 '24 11:08 leofang

I don't have specific requests for details. Let me just say that I submitted this issue with numpy.typing in mind: I know it cannot be exhaustive (ex. undocumented/internal modules can be untyped) or complete (ex. return type can be Any if too complex/array dtype can be missing) in principle. Thank you in advance!

EarlMilktea avatar Aug 26 '24 12:08 EarlMilktea

Any updates?

EarlMilktea avatar Jun 09 '25 18:06 EarlMilktea