-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mypy stub files to PyAV #642
Comments
I'd very much enjoy having such stubs! However, having already written stubs for a fairly large project ( |
Yes sure, if I get to it I will submit a PR. |
Is there any way to auto-generate this from the Cython source? I'm not looking forward to maintaining the stub files in the future, and if it can be a near-automatic process it is more likely to be maintained by me. |
Yes and no, there is a mypy stub generator for cpython files, but that requires pyx files with every type indicated. If it's not the case the stubgen will create stub files with any type indicated as any, which doesn't really help. For example this will be the result on the descriptor.pyx file:
So the (only) possible solution would be to refactor the whole library to use these type hints. |
Another (smaller) step would be to follow up on the promise here https://github.com/PyAV-Org/PyAV/blob/develop/av/__init__.py#L14 and import anything into the __init__.py, and not just the things that are human constructable, so that IDEs like PyCharm can at least auto-complete the class names. |
Couldn't we just start slowly? PyAV supports Python from 3.5 on, so adding type annotations shouldn't break anything. |
Hi. |
Great, I look forward to your pull request! |
But when function signatures changed or new functions been add, the |
|
@moi90 I'm unfamiliar with how to include type annotations for Cython code, but on principle yes I would prefer them to be straight in the code if that is possible. |
@jlaine Ah, yes. Compiled modules will require Anyways, the annotations produced by |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This shouldn't be closed, I think this could be very valuable for users of the library. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I get missing stub files. Related: #1065 Would adding a |
No, the problem is, that no type annotations are available at all. It would be tedious to add them manually and keep them up to date. And, so far, is not easy to extract typing information from Cython code automatically. Apart from |
Overview
To simplify developing and linting with PyAV, stub files should be included. explanation of stubs
Desired Behavior
Every object / method should have defined stubs, which are detectable by IDEs such as PyCharm aswell as typical linters like MyPy.
Example API
Not relevant for this problem (?)
Additional context
For futher explanation see: https://www.python.org/dev/peps/pep-0484/
A possible solution could be using a stub generator like stubgen.
The text was updated successfully, but these errors were encountered: