python-betterproto icon indicating copy to clipboard operation
python-betterproto copied to clipboard

types: make everything type check

Open Gobot1234 opened this issue 2 years ago • 10 comments

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, ...)

Gobot1234 avatar Oct 28 '23 22:10 Gobot1234

No idea where this pkg_resources failure came from

Gobot1234 avatar Oct 28 '23 22:10 Gobot1234

@cetanu do you have any idea why the tests are failing?

Gobot1234 avatar Nov 01 '23 00:11 Gobot1234

Looking now...

cetanu avatar Nov 01 '23 00:11 cetanu

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

cetanu avatar Nov 01 '23 00:11 cetanu

https://github.com/grpc/grpc/blob/master/tools/distrib/python/grpcio_tools/grpc_tools/protoc.py#L21

cetanu avatar Nov 01 '23 00:11 cetanu

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)

cetanu avatar Nov 01 '23 00:11 cetanu

I'll just send a PR to fix it

Gobot1234 avatar Dec 16 '23 14:12 Gobot1234

@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.

tzahush avatar Mar 04 '24 08:03 tzahush