Skip to content
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

Type hint stubs #491

Closed
paravoid opened this issue Dec 3, 2019 · 4 comments
Closed

Type hint stubs #491

paravoid opened this issue Dec 3, 2019 · 4 comments

Comments

@paravoid
Copy link

paravoid commented Dec 3, 2019

It'd be awesome if client_python was type hinted, as that would allow downstream consumers to typecheck their API calls (one has to explicitly # type: ignore the import right now).

My understanding is that the project is actively trying to support (very) old versions of Python. In this case, there are two options: a) type hints in comments b) type stubs (.pyi). The latter is preferrable; this can be shipped by either typeshed, or, ideally, in the software itself. For more about the pros and cons of each solution, I've found Bernat Gabor's blog post to be informative.

Adding the hints across the entire code base is easy but still, not a trivial amount of work. Tools like MonkeyType can help bootstrap that process. Given the good code test coverage, I tried running the test suite with MonkeyType (monkeytype run -m pytest) and it generated the majority of the hints. There were, however, some corner cases that it wasn't able to figure out or otherwise failed to generate, and I'm not familiar enough with the codebase to help with that.

Thanks & thanks for all of the work you've been putting on this module!

@brian-brazil
Copy link
Contributor

This seems reasonable to add to the public bits of the API via comments.

My understanding is that the project is actively trying to support (very) old versions of Python.

More that we're not going to drop them until they cause too much hassle, so far it has only been a little annoying.

@takeda
Copy link
Contributor

takeda commented Oct 9, 2021

@brian-brazil type hints can still be added using # type: comments, here's more: https://mypy.readthedocs.io/en/stable/python2.html (this is another alternative: https://mypy.readthedocs.io/en/stable/stubs.html, but it is worse since types get easilly out of sync with the code)

I found this ticket, because I am getting bunch of error: Untyped decorator makes function "get_parameter" untyped errors in places where I use a decorator. I would love if a support would be added.

Adding types to Python makes autocomplete and refactoring functionality work well, and of course finds all kinds of bugs in the code.

@akx
Copy link
Contributor

akx commented Jan 11, 2022

#718 dropped support for Python 2 altogether, so real type hints could now be added.

@paravoid
Copy link
Author

I believe type hints now exist, so resolving this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants