-
Notifications
You must be signed in to change notification settings - Fork 340
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
Added Python2 compatible type hints #167
Added Python2 compatible type hints #167
Conversation
Thank you for looking into this, @Avasam |
Do we have to add something in the testing / CI to check whether the typing stuff works? For example, a test that the types are not faulty, and a test that a calling code with the wrong type can be identified by a typing checker. |
the python3.9 CI run is complaining that numpy is too new: |
You could run type checkers to ensure that the returned and used types match the annotations. Popular ones are mypy and pyright. Typeshed also tests against pytyped. I am quite familiar with pyright so I could add it and configure it. A bit less so with the other two, but I don't think it's anything too complicated. Would you like me to add them as part of this PR or separately?
I've noticed that with my other PR as well. Conda doesn't support Environment markers (which would be an easy fix), but it has something called Preprocessing selectors instead that we can try to use. |
Unrelated to conda. The step that tested the setup.py install (which conda doesn't care about the existence of setup.py) was using a deprecated and obsolete way of installing.
|
I am okay with merging this if it is ready from your side. |
Thank you for your work on this! I suppose I should make a release now. |
You're welcome! I learned a lot about typing since I opened the issue last year. So I decided to give it a go. And it's better to have it directly as part of the library rather than in typeshed. |
release 4.3 is out, please test it and let me know whether it works for you. I made some substantial changes in the code regarding python version checking, hope it did not break things. If it did, we need better CI checks. |
Closes #151
Just like #161, but addresses @JohannesBuchner concerns #151 (comment)
The refactor from a single file module to a package was necessary for the inclusion of
py.typed
, which lets type checkers know to not look for type stubs as types are inlined.See: https://peps.python.org/pep-0561/#packaging-type-information