-
Notifications
You must be signed in to change notification settings - Fork 435
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 type hints #505
Comments
Unfortunately one of the selling points of the library is compatibility with older Python versions, often necessary in some enterprise environments. Right now the library supports even Python 2.7, and type hints would eliminate that feature. I'll continue monitoring community usage, and if Python 2-3.4 support is not necessary anymore, I'll drop it and add type hints. Edit: I guess I could add at least a stub file for MyPy without breaking compatibility. I'll look into it. |
.pyi files (type stubs) are the way to go in this case. Here's auto generated ones by Pylance. I've already filled in some that I use, namely |
@boppreh You can have inline typing in Python2 code by using type comments https://mypy.readthedocs.io/en/stable/python2.html |
3rd party keyboard type stubs (by myself) have been added to typeshed python/typeshed#8666 It'd be best if the stubs were part of keyboard itself. You should be able to use them directly from typeshed (and they should be fairly accurate). Although they also wouldn't be removed from typeshed until a PyPI release of keyboard includes the stubs. Ultimately, the best scenario is to have inline typing directly, as it reduces chances of desync between stubs and implementation, and allows for easy type-checking in the CI and during development. However, due to the Python2 support requirement, inline type comments may be annoying, and will be more complicated to support multiple Python version while trying to keep typing as accurate as possible depending on what said version supports. |
Please add type hints to the functions
The text was updated successfully, but these errors were encountered: