rtree
rtree copied to clipboard
Type hinting for the code
Hello!
I think it'll be useful to add type hints to the python code here to make it more self-documented and clearly expressed. If you think that this is a good idea, I can take the task and make this myself.
I'm enthusiastic about the type hints, but I don't know what minimum Python version that would end up causing Rtree to be limited to. Does support degrade smoothly back to Python 3.6?
@hobu, I think yes, the compatibility with older versions will be dropped upon the creation of the hinting system. Maybe if the support of older python needed, the string hints can be written (which are compatible with type checkers such as mypy).
Type hints were first added to Python 3.5. There have been a lot of improvements since then, but if you need to maintain support for Python 3.5 or 3.6, it shouldn't be hard to do. There are ways to support older versions of Python too by adding the type hints in comments.
If someone wants to make a PR adding these, I would be happy to merge it.
@samgans I'm adding type hints to many (but not all) functions/classes in #215. Let me know if you want to help. I can also finish the major classes and let you handle the details in a follow-up PR if that works better.
#215 has now been merged. There's definitely still a lot of functions that need type hints added to them, but the majority of user-facing functions now have type hints. @samgans feel free to add more and I'll review!
I'm very excited for type annotations for Rtree - thanks for all the work so far. Unfortunately I noticed that Mypy gave some warnings with the v1.0.0 Rtree. I just opened https://github.com/Toblerity/rtree/pull/243 as I think would fix that issue - @hobu @adamjstewart let me know what you think or if you have other thoughts on how to ensure Rtree type annotations work properly in user projects. Thanks!