-
-
Notifications
You must be signed in to change notification settings - Fork 90
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 #384
Comments
I'd love to see type hints here in Cheroot and in CherryPy. The next major release is supposed to be dropping py2 so it's possible to use native syntax. OTOH, we could also try pyi files or comment-based hints for something to be available in the 8.x stream. PR is welcome :) |
@webknjaz Let me try to add some more context and ideas
I'm happy to file a PR adding mypy and some utility stuff. I can also try to add some types by my own but I guess help of the actual core developers will be needed. In addition it should be decided, if you would like to type your whole codebase or only the public API. That's btw just my view, so please feel free to add yours π |
There's more to it. We were thinking about keeping the 8.x for bugfixes. This means that we'd need to backport things from the newer versions. Active use of the newer syntax would mean the need to manually resolve conflicts, which adds to the maintainance burden. OTOH if the code base is similar enough,
No, pyi files can also live in the project next to their counterparts.
You can count on me for reviews. Also, the mypy integration should go to the pre-commit.com config FYI. Oh, and a bonus though: it'd be interesting to also use all of the other type checkers that exist, at least in the CI. Because the users or Pyro or other stuff would get different results compared to the mypy users and we need to be compliant with all of these. |
Sorry for the late reply. I agree with you, pyi files seem to be the best solution. If it's fine for you, I'll try to add some base hints for e.g. the |
Sounds good. Note that I'm on vacation and may be unable to review for a week or two. |
So, the first part was now merged. However, certain parts are missing:
|
@webknjaz can you please share your opinion about typing in tests. Personally I do that in my projects, but I use inline types ( |
@kasium can we go for inline type comments in tests? |
@webknjaz aren't they also execute in python2? If yes, type comments would be the only way since the syntax is py3 only |
That's exactly what I was suggesting. |
@webknjaz what should we do with private methods? If they are not part of the pyi files, mypy complains in tests |
In that case β yes. |
@webknjaz I'll try to work on the open points in the next time |
Sure, no hurry. Thanks! |
Hi, is there something left to be done here? Which files specifically need to be annotated? |
@mgrabovsky I guess this is done |
@kasium it seems like there's something in your TODO comment at #384 (comment) that could be imrpoved. @mgrabovsky if you want to contribute improvements, you could look at replacing the |
Ah right. Thanks π Yes, the types could be improved but else the item is finished |
β I'm submitting a ...
π£ Describe the solution you'd like
It would be great to see the python 3.5+ type hints in the repository, especially for the
Server
api.π Describe alternatives you've considered
Adding type stubs to typeshed (https://github.com/python/typeshed/tree/master/stubs).
If you think this makes more sense, that's possible. But I first wanted to ask here.
The text was updated successfully, but these errors were encountered: