google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

Include mypy types

Open devnev opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Modern python can be type-checked using mypy, but the python distribution of this package does not include the type specs, nor is there a companion type package.

Describe the solution you'd like

Types generated using e.g. https://pypi.org/project/mypy-protobuf/ included either directly in the python googleapis-common-protos package or a separate googleapis-common-protos-stubs package. A separate stubs package might help with avoiding accidental breakage.

Describe alternatives you've considered

I could check in the googleapi protos into the repository where I'm using them and add codegen from that.

Additional context For the grpcio packages, there's stubs maintained by a third-party, https://pypi.org/project/grpc-stubs/. The protoc plugin https://pypi.org/project/mypy-protobuf/ codegens stubs for proto files (messages and grpc clients/handlers).

devnev avatar Nov 29 '22 15:11 devnev

Transferring this issue to google-cloud-python as the code for python-api-common-protos will be migrated there.

parthea avatar Dec 16 '24 16:12 parthea

*.pyi files are included in https://github.com/googleapis/google-cloud-python/tree/main/packages/googleapis-common-protos/google/api

There is an open issue in protocolbuffers/protobuf where mypy fails with ClassVar can only be used for assignments in class body: https://github.com/protocolbuffers/protobuf/issues/13700 . I'll keep this issue open until that's addressed.

google/cloud/extended_operations_pb2.pyi:36: error: ClassVar can only be used for assignments in class body  [misc]
google/cloud/extended_operations_pb2.pyi:38: error: ClassVar can only be used for assignments in class body  [misc]
google/cloud/extended_operations_pb2.pyi:40: error: ClassVar can only be used for assignments in class body  [misc]
google/cloud/extended_operations_pb2.pyi:42: error: ClassVar can only be used for assignments in class body  [misc]
google/cloud/extended_operations_pb2.pyi:44: error: ClassVar can only be used for assignments in class body  [misc]
google/api/visibility_pb2.pyi:27: error: ClassVar can only be used for assignments in class body  [misc]
google/api/visibility_pb2.pyi:29: error: ClassVar can only be used for assignments in class body  [misc]
google/api/visibility_pb2.pyi:31: error: ClassVar can only be used for assignments in class body  [misc]
google/api/visibility_pb2.pyi:33: error: ClassVar can only be used for assignments in class body  [misc]
google/api/visibility_pb2.pyi:35: error: ClassVar can only be used for assignments in class body  [misc]
google/api/visibility_pb2.pyi:37: error: ClassVar can only be used for assignments in class body  [misc]
google/api/routing_pb2.pyi:27: error: ClassVar can only be used for assignments in class body  [misc]
google/api/resource_pb2.pyi:27: error: ClassVar can only be used for assignments in class body  [misc]
google/api/resource_pb2.pyi:29: error: ClassVar can only be used for assignments in class body  [misc]
google/api/resource_pb2.pyi:31: error: ClassVar can only be used for assignments in class body  [misc]
google/api/policy_pb2.pyi:27: error: ClassVar can only be used for assignments in class body  [misc]
google/api/policy_pb2.pyi:29: error: ClassVar can only be used for assignments in class body  [misc]
google/api/field_info_pb2.pyi:28: error: ClassVar can only be used for assignments in class body  [misc]
google/api/field_behavior_pb2.pyi:44: error: ClassVar can only be used for assignments in class body  [misc]
google/api/annotations_pb2.pyi:23: error: ClassVar can only be used for assignments in class body  [misc]
google/api/client_pb2.pyi:60: error: ClassVar can only be used for assignments in class body  [misc]
google/api/client_pb2.pyi:62: error: ClassVar can only be used for assignments in class body  [misc]
google/api/client_pb2.pyi:64: error: ClassVar can only be used for assignments in class body  [misc]
google/api/client_pb2.pyi:66: error: ClassVar can only be used for assignments in class body  [misc]

parthea avatar Mar 23 '25 10:03 parthea