types: make everything type check
Summary
Use more 3.7+ features in the library and make everything type check. This also adds support for using the union operator for python 3.10+ for Union/Optional
Checklist
- [x] If code changes were made then they have been tested.
- [x] I have updated the documentation to reflect the changes.
- [ ] This PR fixes an issue.
- [ ] This PR adds something new (e.g. new method or parameters).
- [ ] This change has an associated test.
- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
- [ ] This PR is not a code change (e.g. documentation, README, ...)
No idea where this pkg_resources failure came from
@cetanu do you have any idea why the tests are failing?
Looking now...
It appears to be related to this
https://github.com/grpc/grpc/issues/33570
but it's just a deprecation warning? I think we can catch this
https://github.com/grpc/grpc/blob/master/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py#L21
Since this is only for generating the tests, we could do something very hacky
import re
from importlib import resources
file = resources.files("grpc_tools") / Path("protoc.py")
content = file.read_text()
if "import pkg_resources" in content:
content = re.sub(
pattern="import pkg_resources",
repl=r"try:\n import pkg_resources\nexcept DeprecationWarning:\n pass",
string=content,
)
file.open().write(content)
I'll just send a PR to fix it
@Gobot1234 I see the PR that we were waiting for here https://github.com/grpc/grpc/pull/35329 is closed, what should we do as next steps? perhaps this was fixed in different PR's.