Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I've just started to use grpclib and I noticed in #40 that you asked for help in typing the library, so here you go!
I've added type hints to most of the internals of grpclib as well as the streams that are exposed to users.
Due to the relative new-ness of type annotation in python I've had to bump the supported version of Python to 3.5.2, but as tox shows this PR passes all tests and lints fine. Mypy is also fine in non strict mode.
With this I've typed the examples, and introducing an error such as
will throws a mypy error like
The main areas where I haven't introduced types are around the untyped h2 library and in areas where I'm unsure of the exact type (e.g. Metadata).
Let me know if I've made any of them too restrictive or if you have any other comments and I'll try to sort these out!