paleolimbot commented on issue #32609:
URL: https://github.com/apache/arrow/issues/32609#issuecomment-2112805759

   I've experimented a little with this in nanoarrow (where I'd at least like 
to get autocomplete for methods on some objects that have to be implemented in 
Cython) and found a few things that might be helpful:
   
   - mypy can generate stubs that include docstrings for class methods. This 
does not include documentation for the classes themselves, nor does it include 
*functions* (no class) implemented in Cython, nor does it include any typing 
hints provided inline in Cython.
   - One low-maintenance intervention to improve the situation is to move or 
copy some function definitions to Python (e.g., `def int32() -> DataType`).
   - Pretty much every solution I found listed on google to generate stubs from 
Cython generates very bad stubs.
   
   I would lean towards some kind of programmatic approach where type hinting 
is specified in a docstring or something to minimize the pain of keeping .pxi 
files synced. Off the top of my head, I would probably start with the 
mypy-generated stubs, parse it into an ast, do some transformation to add type 
hints based on some pattern in the docstring or parsing of the argument list 
(Cython methods provide the file number and line number of the definition). 
That is almost certainly a can of worms (but so are any alternatives I know 
about).
   
   The PR adding very basic mypy stubs to nanoarrow is here: 
https://github.com/apache/arrow-nanoarrow/pull/468


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to