From ac15e1c5c1d8e97b96be76734099eceb1f12d5c3 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 20 Jun 2024 17:54:02 -0400 Subject: [PATCH] fix: regenerate pb2 files for compatibility with protobuf 5.x (#97) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: regenerate pb2 files for compatibility with protobuf 5.x * fix build * clean up * lint * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * clean up * lint * fix build * filter downstream warnings * filter downstream warnings * filter downstream warnings --------- Co-authored-by: Owl Bot --- .github/workflows/unittest.yml | 3 +- google/iam/v1/iam_policy_pb2.py | 81 ++------ google/iam/v1/logging/audit_data_pb2.py | 24 +-- google/iam/v1/options_pb2.py | 24 +-- google/iam/v1/policy_pb2.py | 135 +++---------- noxfile.py | 229 ++++++++++++++-------- owlbot.py | 2 +- pytest.ini | 8 + setup.py | 2 +- testing/constraints-3.7-python-pubsub.txt | 9 + testing/constraints-3.7.txt | 9 + testing/constraints-3.8.txt | 9 + testing/constraints-3.9-python-pubsub.txt | 0 13 files changed, 242 insertions(+), 293 deletions(-) create mode 100644 testing/constraints-3.7-python-pubsub.txt create mode 100644 testing/constraints-3.9-python-pubsub.txt diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index f4a337c..4993b4f 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -24,7 +24,8 @@ jobs: env: COVERAGE_FILE: .coverage-${{ matrix.python }} run: | - nox -s unit-${{ matrix.python }} + nox -s unit_local-${{ matrix.python }} + nox -s unit_remote-${{ matrix.python }} - name: Upload coverage results uses: actions/upload-artifact@v4 with: diff --git a/google/iam/v1/iam_policy_pb2.py b/google/iam/v1/iam_policy_pb2.py index a80bed8..d3a8e4c 100644 --- a/google/iam/v1/iam_policy_pb2.py +++ b/google/iam/v1/iam_policy_pb2.py @@ -19,9 +19,8 @@ """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) @@ -41,62 +40,12 @@ b'\n\x1egoogle/iam/v1/iam_policy.proto\x12\rgoogle.iam.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/iam/v1/options.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a google/protobuf/field_mask.proto"\x8f\x01\n\x13SetIamPolicyRequest\x12\x1b\n\x08resource\x18\x01 \x01(\tB\t\xe0\x41\x02\xfa\x41\x03\n\x01*\x12*\n\x06policy\x18\x02 \x01(\x0b\x32\x15.google.iam.v1.PolicyB\x03\xe0\x41\x02\x12/\n\x0bupdate_mask\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.FieldMask"d\n\x13GetIamPolicyRequest\x12\x1b\n\x08resource\x18\x01 \x01(\tB\t\xe0\x41\x02\xfa\x41\x03\n\x01*\x12\x30\n\x07options\x18\x02 \x01(\x0b\x32\x1f.google.iam.v1.GetPolicyOptions"R\n\x19TestIamPermissionsRequest\x12\x1b\n\x08resource\x18\x01 \x01(\tB\t\xe0\x41\x02\xfa\x41\x03\n\x01*\x12\x18\n\x0bpermissions\x18\x02 \x03(\tB\x03\xe0\x41\x02"1\n\x1aTestIamPermissionsResponse\x12\x13\n\x0bpermissions\x18\x01 \x03(\t2\xb4\x03\n\tIAMPolicy\x12t\n\x0cSetIamPolicy\x12".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy")\x82\xd3\xe4\x93\x02#"\x1e/v1/{resource=**}:setIamPolicy:\x01*\x12t\n\x0cGetIamPolicy\x12".google.iam.v1.GetIamPolicyRequest\x1a\x15.google.iam.v1.Policy")\x82\xd3\xe4\x93\x02#"\x1e/v1/{resource=**}:getIamPolicy:\x01*\x12\x9a\x01\n\x12TestIamPermissions\x12(.google.iam.v1.TestIamPermissionsRequest\x1a).google.iam.v1.TestIamPermissionsResponse"/\x82\xd3\xe4\x93\x02)"$/v1/{resource=**}:testIamPermissions:\x01*\x1a\x1e\xca\x41\x1biam-meta-api.googleapis.comB\x7f\n\x11\x63om.google.iam.v1B\x0eIamPolicyProtoP\x01Z)cloud.google.com/go/iam/apiv1/iampb;iampb\xf8\x01\x01\xaa\x02\x13Google.Cloud.Iam.V1\xca\x02\x13Google\\Cloud\\Iam\\V1b\x06proto3' ) - -_SETIAMPOLICYREQUEST = DESCRIPTOR.message_types_by_name["SetIamPolicyRequest"] -_GETIAMPOLICYREQUEST = DESCRIPTOR.message_types_by_name["GetIamPolicyRequest"] -_TESTIAMPERMISSIONSREQUEST = DESCRIPTOR.message_types_by_name[ - "TestIamPermissionsRequest" -] -_TESTIAMPERMISSIONSRESPONSE = DESCRIPTOR.message_types_by_name[ - "TestIamPermissionsResponse" -] -SetIamPolicyRequest = _reflection.GeneratedProtocolMessageType( - "SetIamPolicyRequest", - (_message.Message,), - { - "DESCRIPTOR": _SETIAMPOLICYREQUEST, - "__module__": "google.iam.v1.iam_policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.SetIamPolicyRequest) - }, -) -_sym_db.RegisterMessage(SetIamPolicyRequest) - -GetIamPolicyRequest = _reflection.GeneratedProtocolMessageType( - "GetIamPolicyRequest", - (_message.Message,), - { - "DESCRIPTOR": _GETIAMPOLICYREQUEST, - "__module__": "google.iam.v1.iam_policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.GetIamPolicyRequest) - }, -) -_sym_db.RegisterMessage(GetIamPolicyRequest) - -TestIamPermissionsRequest = _reflection.GeneratedProtocolMessageType( - "TestIamPermissionsRequest", - (_message.Message,), - { - "DESCRIPTOR": _TESTIAMPERMISSIONSREQUEST, - "__module__": "google.iam.v1.iam_policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.TestIamPermissionsRequest) - }, +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages( + DESCRIPTOR, "google.iam.v1.iam_policy_pb2", _globals ) -_sym_db.RegisterMessage(TestIamPermissionsRequest) - -TestIamPermissionsResponse = _reflection.GeneratedProtocolMessageType( - "TestIamPermissionsResponse", - (_message.Message,), - { - "DESCRIPTOR": _TESTIAMPERMISSIONSRESPONSE, - "__module__": "google.iam.v1.iam_policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.TestIamPermissionsResponse) - }, -) -_sym_db.RegisterMessage(TestIamPermissionsResponse) - -_IAMPOLICY = DESCRIPTOR.services_by_name["IAMPolicy"] if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\021com.google.iam.v1B\016IamPolicyProtoP\001Z)cloud.google.com/go/iam/apiv1/iampb;iampb\370\001\001\252\002\023Google.Cloud.Iam.V1\312\002\023Google\\Cloud\\Iam\\V1" _SETIAMPOLICYREQUEST.fields_by_name["resource"]._options = None @@ -137,14 +86,14 @@ ]._serialized_options = ( b'\202\323\344\223\002)"$/v1/{resource=**}:testIamPermissions:\001*' ) - _SETIAMPOLICYREQUEST._serialized_start = 256 - _SETIAMPOLICYREQUEST._serialized_end = 399 - _GETIAMPOLICYREQUEST._serialized_start = 401 - _GETIAMPOLICYREQUEST._serialized_end = 501 - _TESTIAMPERMISSIONSREQUEST._serialized_start = 503 - _TESTIAMPERMISSIONSREQUEST._serialized_end = 585 - _TESTIAMPERMISSIONSRESPONSE._serialized_start = 587 - _TESTIAMPERMISSIONSRESPONSE._serialized_end = 636 - _IAMPOLICY._serialized_start = 639 - _IAMPOLICY._serialized_end = 1075 + _globals["_SETIAMPOLICYREQUEST"]._serialized_start = 256 + _globals["_SETIAMPOLICYREQUEST"]._serialized_end = 399 + _globals["_GETIAMPOLICYREQUEST"]._serialized_start = 401 + _globals["_GETIAMPOLICYREQUEST"]._serialized_end = 501 + _globals["_TESTIAMPERMISSIONSREQUEST"]._serialized_start = 503 + _globals["_TESTIAMPERMISSIONSREQUEST"]._serialized_end = 585 + _globals["_TESTIAMPERMISSIONSRESPONSE"]._serialized_start = 587 + _globals["_TESTIAMPERMISSIONSRESPONSE"]._serialized_end = 636 + _globals["_IAMPOLICY"]._serialized_start = 639 + _globals["_IAMPOLICY"]._serialized_end = 1075 # @@protoc_insertion_point(module_scope) diff --git a/google/iam/v1/logging/audit_data_pb2.py b/google/iam/v1/logging/audit_data_pb2.py index 31a8376..8a815b6 100644 --- a/google/iam/v1/logging/audit_data_pb2.py +++ b/google/iam/v1/logging/audit_data_pb2.py @@ -19,9 +19,8 @@ """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) @@ -35,23 +34,14 @@ b'\n&google/iam/v1/logging/audit_data.proto\x12\x15google.iam.v1.logging\x1a\x1agoogle/iam/v1/policy.proto"=\n\tAuditData\x12\x30\n\x0cpolicy_delta\x18\x02 \x01(\x0b\x32\x1a.google.iam.v1.PolicyDeltaB\x86\x01\n\x19\x63om.google.iam.v1.loggingB\x0e\x41uditDataProtoP\x01Z9cloud.google.com/go/iam/apiv1/logging/loggingpb;loggingpb\xaa\x02\x1bGoogle.Cloud.Iam.V1.Loggingb\x06proto3' ) - -_AUDITDATA = DESCRIPTOR.message_types_by_name["AuditData"] -AuditData = _reflection.GeneratedProtocolMessageType( - "AuditData", - (_message.Message,), - { - "DESCRIPTOR": _AUDITDATA, - "__module__": "google.iam.v1.logging.audit_data_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.logging.AuditData) - }, +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages( + DESCRIPTOR, "google.iam.v1.logging.audit_data_pb2", _globals ) -_sym_db.RegisterMessage(AuditData) - if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\031com.google.iam.v1.loggingB\016AuditDataProtoP\001Z9cloud.google.com/go/iam/apiv1/logging/loggingpb;loggingpb\252\002\033Google.Cloud.Iam.V1.Logging" - _AUDITDATA._serialized_start = 93 - _AUDITDATA._serialized_end = 154 + _globals["_AUDITDATA"]._serialized_start = 93 + _globals["_AUDITDATA"]._serialized_end = 154 # @@protoc_insertion_point(module_scope) diff --git a/google/iam/v1/options_pb2.py b/google/iam/v1/options_pb2.py index 2ec029b..85dcd90 100644 --- a/google/iam/v1/options_pb2.py +++ b/google/iam/v1/options_pb2.py @@ -19,9 +19,8 @@ """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) @@ -32,23 +31,14 @@ b'\n\x1bgoogle/iam/v1/options.proto\x12\rgoogle.iam.v1"4\n\x10GetPolicyOptions\x12 \n\x18requested_policy_version\x18\x01 \x01(\x05\x42}\n\x11\x63om.google.iam.v1B\x0cOptionsProtoP\x01Z)cloud.google.com/go/iam/apiv1/iampb;iampb\xf8\x01\x01\xaa\x02\x13Google.Cloud.Iam.V1\xca\x02\x13Google\\Cloud\\Iam\\V1b\x06proto3' ) - -_GETPOLICYOPTIONS = DESCRIPTOR.message_types_by_name["GetPolicyOptions"] -GetPolicyOptions = _reflection.GeneratedProtocolMessageType( - "GetPolicyOptions", - (_message.Message,), - { - "DESCRIPTOR": _GETPOLICYOPTIONS, - "__module__": "google.iam.v1.options_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.GetPolicyOptions) - }, +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages( + DESCRIPTOR, "google.iam.v1.options_pb2", _globals ) -_sym_db.RegisterMessage(GetPolicyOptions) - if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\021com.google.iam.v1B\014OptionsProtoP\001Z)cloud.google.com/go/iam/apiv1/iampb;iampb\370\001\001\252\002\023Google.Cloud.Iam.V1\312\002\023Google\\Cloud\\Iam\\V1" - _GETPOLICYOPTIONS._serialized_start = 46 - _GETPOLICYOPTIONS._serialized_end = 98 + _globals["_GETPOLICYOPTIONS"]._serialized_start = 46 + _globals["_GETPOLICYOPTIONS"]._serialized_end = 98 # @@protoc_insertion_point(module_scope) diff --git a/google/iam/v1/policy_pb2.py b/google/iam/v1/policy_pb2.py index b6057f3..b8f663f 100644 --- a/google/iam/v1/policy_pb2.py +++ b/google/iam/v1/policy_pb2.py @@ -19,9 +19,8 @@ """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) @@ -35,116 +34,32 @@ b'\n\x1agoogle/iam/v1/policy.proto\x12\rgoogle.iam.v1\x1a\x16google/type/expr.proto"\x84\x01\n\x06Policy\x12\x0f\n\x07version\x18\x01 \x01(\x05\x12(\n\x08\x62indings\x18\x04 \x03(\x0b\x32\x16.google.iam.v1.Binding\x12\x31\n\raudit_configs\x18\x06 \x03(\x0b\x32\x1a.google.iam.v1.AuditConfig\x12\x0c\n\x04\x65tag\x18\x03 \x01(\x0c"N\n\x07\x42inding\x12\x0c\n\x04role\x18\x01 \x01(\t\x12\x0f\n\x07members\x18\x02 \x03(\t\x12$\n\tcondition\x18\x03 \x01(\x0b\x32\x11.google.type.Expr"X\n\x0b\x41uditConfig\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x38\n\x11\x61udit_log_configs\x18\x03 \x03(\x0b\x32\x1d.google.iam.v1.AuditLogConfig"\xb7\x01\n\x0e\x41uditLogConfig\x12\x37\n\x08log_type\x18\x01 \x01(\x0e\x32%.google.iam.v1.AuditLogConfig.LogType\x12\x18\n\x10\x65xempted_members\x18\x02 \x03(\t"R\n\x07LogType\x12\x18\n\x14LOG_TYPE_UNSPECIFIED\x10\x00\x12\x0e\n\nADMIN_READ\x10\x01\x12\x0e\n\nDATA_WRITE\x10\x02\x12\r\n\tDATA_READ\x10\x03"\x80\x01\n\x0bPolicyDelta\x12\x33\n\x0e\x62inding_deltas\x18\x01 \x03(\x0b\x32\x1b.google.iam.v1.BindingDelta\x12<\n\x13\x61udit_config_deltas\x18\x02 \x03(\x0b\x32\x1f.google.iam.v1.AuditConfigDelta"\xbd\x01\n\x0c\x42indingDelta\x12\x32\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32".google.iam.v1.BindingDelta.Action\x12\x0c\n\x04role\x18\x02 \x01(\t\x12\x0e\n\x06member\x18\x03 \x01(\t\x12$\n\tcondition\x18\x04 \x01(\x0b\x32\x11.google.type.Expr"5\n\x06\x41\x63tion\x12\x16\n\x12\x41\x43TION_UNSPECIFIED\x10\x00\x12\x07\n\x03\x41\x44\x44\x10\x01\x12\n\n\x06REMOVE\x10\x02"\xbd\x01\n\x10\x41uditConfigDelta\x12\x36\n\x06\x61\x63tion\x18\x01 \x01(\x0e\x32&.google.iam.v1.AuditConfigDelta.Action\x12\x0f\n\x07service\x18\x02 \x01(\t\x12\x17\n\x0f\x65xempted_member\x18\x03 \x01(\t\x12\x10\n\x08log_type\x18\x04 \x01(\t"5\n\x06\x41\x63tion\x12\x16\n\x12\x41\x43TION_UNSPECIFIED\x10\x00\x12\x07\n\x03\x41\x44\x44\x10\x01\x12\n\n\x06REMOVE\x10\x02\x42|\n\x11\x63om.google.iam.v1B\x0bPolicyProtoP\x01Z)cloud.google.com/go/iam/apiv1/iampb;iampb\xf8\x01\x01\xaa\x02\x13Google.Cloud.Iam.V1\xca\x02\x13Google\\Cloud\\Iam\\V1b\x06proto3' ) - -_POLICY = DESCRIPTOR.message_types_by_name["Policy"] -_BINDING = DESCRIPTOR.message_types_by_name["Binding"] -_AUDITCONFIG = DESCRIPTOR.message_types_by_name["AuditConfig"] -_AUDITLOGCONFIG = DESCRIPTOR.message_types_by_name["AuditLogConfig"] -_POLICYDELTA = DESCRIPTOR.message_types_by_name["PolicyDelta"] -_BINDINGDELTA = DESCRIPTOR.message_types_by_name["BindingDelta"] -_AUDITCONFIGDELTA = DESCRIPTOR.message_types_by_name["AuditConfigDelta"] -_AUDITLOGCONFIG_LOGTYPE = _AUDITLOGCONFIG.enum_types_by_name["LogType"] -_BINDINGDELTA_ACTION = _BINDINGDELTA.enum_types_by_name["Action"] -_AUDITCONFIGDELTA_ACTION = _AUDITCONFIGDELTA.enum_types_by_name["Action"] -Policy = _reflection.GeneratedProtocolMessageType( - "Policy", - (_message.Message,), - { - "DESCRIPTOR": _POLICY, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.Policy) - }, -) -_sym_db.RegisterMessage(Policy) - -Binding = _reflection.GeneratedProtocolMessageType( - "Binding", - (_message.Message,), - { - "DESCRIPTOR": _BINDING, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.Binding) - }, -) -_sym_db.RegisterMessage(Binding) - -AuditConfig = _reflection.GeneratedProtocolMessageType( - "AuditConfig", - (_message.Message,), - { - "DESCRIPTOR": _AUDITCONFIG, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.AuditConfig) - }, -) -_sym_db.RegisterMessage(AuditConfig) - -AuditLogConfig = _reflection.GeneratedProtocolMessageType( - "AuditLogConfig", - (_message.Message,), - { - "DESCRIPTOR": _AUDITLOGCONFIG, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.AuditLogConfig) - }, +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages( + DESCRIPTOR, "google.iam.v1.policy_pb2", _globals ) -_sym_db.RegisterMessage(AuditLogConfig) - -PolicyDelta = _reflection.GeneratedProtocolMessageType( - "PolicyDelta", - (_message.Message,), - { - "DESCRIPTOR": _POLICYDELTA, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.PolicyDelta) - }, -) -_sym_db.RegisterMessage(PolicyDelta) - -BindingDelta = _reflection.GeneratedProtocolMessageType( - "BindingDelta", - (_message.Message,), - { - "DESCRIPTOR": _BINDINGDELTA, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.BindingDelta) - }, -) -_sym_db.RegisterMessage(BindingDelta) - -AuditConfigDelta = _reflection.GeneratedProtocolMessageType( - "AuditConfigDelta", - (_message.Message,), - { - "DESCRIPTOR": _AUDITCONFIGDELTA, - "__module__": "google.iam.v1.policy_pb2" - # @@protoc_insertion_point(class_scope:google.iam.v1.AuditConfigDelta) - }, -) -_sym_db.RegisterMessage(AuditConfigDelta) - if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\021com.google.iam.v1B\013PolicyProtoP\001Z)cloud.google.com/go/iam/apiv1/iampb;iampb\370\001\001\252\002\023Google.Cloud.Iam.V1\312\002\023Google\\Cloud\\Iam\\V1" - _POLICY._serialized_start = 70 - _POLICY._serialized_end = 202 - _BINDING._serialized_start = 204 - _BINDING._serialized_end = 282 - _AUDITCONFIG._serialized_start = 284 - _AUDITCONFIG._serialized_end = 372 - _AUDITLOGCONFIG._serialized_start = 375 - _AUDITLOGCONFIG._serialized_end = 558 - _AUDITLOGCONFIG_LOGTYPE._serialized_start = 476 - _AUDITLOGCONFIG_LOGTYPE._serialized_end = 558 - _POLICYDELTA._serialized_start = 561 - _POLICYDELTA._serialized_end = 689 - _BINDINGDELTA._serialized_start = 692 - _BINDINGDELTA._serialized_end = 881 - _BINDINGDELTA_ACTION._serialized_start = 828 - _BINDINGDELTA_ACTION._serialized_end = 881 - _AUDITCONFIGDELTA._serialized_start = 884 - _AUDITCONFIGDELTA._serialized_end = 1073 - _AUDITCONFIGDELTA_ACTION._serialized_start = 828 - _AUDITCONFIGDELTA_ACTION._serialized_end = 881 + _globals["_POLICY"]._serialized_start = 70 + _globals["_POLICY"]._serialized_end = 202 + _globals["_BINDING"]._serialized_start = 204 + _globals["_BINDING"]._serialized_end = 282 + _globals["_AUDITCONFIG"]._serialized_start = 284 + _globals["_AUDITCONFIG"]._serialized_end = 372 + _globals["_AUDITLOGCONFIG"]._serialized_start = 375 + _globals["_AUDITLOGCONFIG"]._serialized_end = 558 + _globals["_AUDITLOGCONFIG_LOGTYPE"]._serialized_start = 476 + _globals["_AUDITLOGCONFIG_LOGTYPE"]._serialized_end = 558 + _globals["_POLICYDELTA"]._serialized_start = 561 + _globals["_POLICYDELTA"]._serialized_end = 689 + _globals["_BINDINGDELTA"]._serialized_start = 692 + _globals["_BINDINGDELTA"]._serialized_end = 881 + _globals["_BINDINGDELTA_ACTION"]._serialized_start = 828 + _globals["_BINDINGDELTA_ACTION"]._serialized_end = 881 + _globals["_AUDITCONFIGDELTA"]._serialized_start = 884 + _globals["_AUDITCONFIGDELTA"]._serialized_end = 1073 + _globals["_AUDITCONFIGDELTA_ACTION"]._serialized_start = 828 + _globals["_AUDITCONFIGDELTA_ACTION"]._serialized_end = 881 # @@protoc_insertion_point(module_scope) diff --git a/noxfile.py b/noxfile.py index 2996a78..f6d638b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -15,20 +15,21 @@ import os import pathlib from pathlib import Path +import re import shutil import nox + BLACK_VERSION = "black==22.3.0" LINT_PATHS = ["docs", "google", "noxfile.py", "setup.py"] -# NOTE: Pin the version of grpcio-tools to 1.48.2 for compatibility with -# Protobuf 3.19.5. Please ensure that the minimum required version of -# protobuf in setup.py is compatible with the pb2 files generated -# by grpcio-tools before changing the pinned version below. -GRPCIO_TOOLS_VERSION = "grpcio-tools==1.48.2" + +# `grpcio-tools` 1.59.0 or newer is required for protobuf 5.x compatibility. +GRPCIO_TOOLS_VERSION = "grpcio-tools==1.59.0" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] @nox.session(python="3.8") @@ -50,83 +51,132 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--strict") -def default(session): +def unit(session, repository, package, prerelease, protobuf_implementation): + """Run the unit test suite.""" + downstream_dir = repository + if package: + downstream_dir = f"{repository}/packages/{package}" + # Install all test dependencies, then install this package in-place. session.install("asyncmock", "pytest-asyncio") - session.install("mock", "pytest", "pytest-cov") - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - - # Install grpc-google-iam-v1 - # This *must* be the last install command to get the package from source. - session.install("-e", ".", "-c", constraints_path) - - # Run py.test against the unit tests. - session.run( - "py.test", - "--quiet", - "--cov=google/cloud", - "--cov=tests/unit", - "--cov-append", - "--cov-config=.coveragerc", - "--cov-report=", - "--cov-fail-under=0", - os.path.join("tests", "unit"), - *session.posargs, - ) - - -@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]) -def unit(session): - """Run the unit test suite.""" - default(session) + # Pin mock due to https://github.com/googleapis/python-pubsub/issues/840 + session.install("mock==5.0.0", "pytest", "pytest-cov") + install_command = ["-e", f"{CURRENT_DIRECTORY}/{downstream_dir}"] -def system(session): - """Run the system test suite.""" - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - # Sanity check: Only run tests if the environment variable is set. - if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): - session.skip("Credentials must be set via environment variable") + if prerelease: + install_prerelease_dependencies( + session, + f"{CURRENT_DIRECTORY}/{downstream_dir}/testing/constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt", + ) + # Use the `--no-deps` options to allow pre-release versions of dependencies to be installed + install_command.extend(["--no-deps"]) + else: + # Install the pinned dependencies in constraints file + install_command.extend( + [ + "-c", + f"{CURRENT_DIRECTORY}/{downstream_dir}/testing/constraints-{session.python}.txt", + ] + ) - system_test_exists = os.path.exists(system_test_path) - system_test_folder_exists = os.path.exists(system_test_folder_path) - # Sanity check: only run tests if found. - if not system_test_exists and not system_test_folder_exists: - session.skip("System tests were not found") + # These *must* be the last 3 install commands to get the packages from source. + session.install(*install_command) - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils") + # Install this library from source + session.install(".", "--no-deps") - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + # Print out package versions of dependencies + session.run( + "python", "-c", "import google.protobuf; print(google.protobuf.__version__)" ) + session.run("python", "-c", "import grpc; print(grpc.__version__)") + session.run("python", "-c", "import google.auth; print(google.auth.__version__)") - # Install grpc-google-iam-v1 - # This *must* be the last install command to get the package from source. - session.install("-e", ".", "-c", constraints_path) + session.run( + "python", "-c", "import google.api_core; print(google.api_core.__version__)" + ) - # Run py.test against the system tests. - if system_test_exists: - session.run("py.test", "--verbose", system_test_path, *session.posargs) - if system_test_folder_exists: - session.run("py.test", "--verbose", system_test_folder_path, *session.posargs) + # Run py.test against the unit tests in the downstream repository + with session.chdir(downstream_dir): + # Run py.test against the unit tests. + session.run( + "py.test", + "--quiet", + "--cov=google/cloud", + "--cov=tests/unit", + "--cov-append", + "--cov-config=.coveragerc", + "--cov-report=", + "--cov-fail-under=0", + os.path.join("tests", "unit"), + *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, + ) -@nox.session(python=["3.6", "3.7", "3.8", "3.9"]) +def install_prerelease_dependencies(session, constraints_path): + with open(constraints_path, encoding="utf-8") as constraints_file: + constraints_text = constraints_file.read() + # Ignore leading whitespace and comment lines. + constraints_deps = [ + match.group(1) + for match in re.finditer( + r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE + ) + ] + session.install(*constraints_deps) + prerel_deps = [ + "googleapis-common-protos", + "protobuf", + "six", + "grpcio", + "grpcio-status", + "google-api-core", + "google-auth", + "proto-plus", + "google-cloud-testutils", + # dependencies of google-cloud-testutils" + "click", + ] + + for dep in prerel_deps: + session.install("--pre", "--no-deps", "--upgrade", dep) + + # Remaining dependencies + other_deps = [ + "requests", + ] + session.install(*other_deps) + + +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) @nox.parametrize( - "library", - ["python-pubsub", "python-texttospeech", "python-speech"], - ids=["pubsub", "texttospeech", "speech"], + "library,prerelease,protobuf_implementation", + [ + (("python-pubsub", None), False, "python"), + (("python-pubsub", None), False, "upb"), + (("python-pubsub", None), False, "cpp"), + (("python-pubsub", None), True, "python"), + (("python-pubsub", None), True, "upb"), + (("python-pubsub", None), True, "cpp"), + (("google-cloud-python", "google-cloud-speech"), False, "python"), + (("google-cloud-python", "google-cloud-speech"), False, "upb"), + (("google-cloud-python", "google-cloud-speech"), False, "cpp"), + (("google-cloud-python", "google-cloud-speech"), True, "python"), + (("google-cloud-python", "google-cloud-speech"), True, "upb"), + (("google-cloud-python", "google-cloud-speech"), True, "cpp"), + ], ) -def test(session, library): +def unit_remote(session, library, prerelease, protobuf_implementation): """Run tests from a downstream libraries. To verify that any changes we make here will not break downstream libraries, clone @@ -136,36 +186,47 @@ def test(session, library): They will need to be updated when the templates change. * Pub/Sub: GAPIC with handwritten layer. - * Text-to-Speech: Full GAPIC. * Speech: Full GAPIC, has long running operations. """ + + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + + repository, package = library try: - session.run("git", "-C", library, "pull", external=True) + session.run("git", "-C", repository, "pull", external=True) except nox.command.CommandFailed: session.run( "git", "clone", "--single-branch", - f"https://github.com/googleapis/{library}", + f"https://github.com/googleapis/{repository}", external=True, ) - session.cd(library) - - default(session) - - # system tests are run on 3.7 only - if session.python == "3.7": - if library == "python-pubsub": - session.install("psutil") - system(session) + unit( + session=session, + repository=repository, + package=package, + prerelease=prerelease, + protobuf_implementation=protobuf_implementation, + ) -@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"]) -def tests_local(session): +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) +@nox.parametrize("protobuf_implementation", ["python", "upb", "cpp"]) +def unit_local(session, protobuf_implementation): """Run tests in this local repo.""" # Install all test dependencies, then install this package in-place. + # TODO(https://github.com/googleapis/proto-plus-python/issues/389): + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf == 3.x however version 3.x + # does not support Python 3.11 and newer. The 'cpp' implementation + # must be excluded from the test matrix for these runtimes. + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + session.skip("cpp implementation is not supported in python 3.11+") + constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) @@ -181,6 +242,11 @@ def tests_local(session): session.install("-e", ".", "-c", constraints_path) + # Remove the 'cpp' implementation once support for Protobuf 3.x is dropped. + # The 'cpp' implementation requires Protobuf<4. + if protobuf_implementation == "cpp": + session.install("protobuf<4") + # Run py.test against the unit tests. session.run( "py.test", @@ -194,6 +260,9 @@ def tests_local(session): "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, + env={ + "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation, + }, ) diff --git a/owlbot.py b/owlbot.py index 8b63dc1..9795013 100644 --- a/owlbot.py +++ b/owlbot.py @@ -58,7 +58,7 @@ s.move(templated_files / "CONTRIBUTING.rst") s.move(templated_files / "*.md") s.move(templated_files / "renovate.json") -s.move(templated_files / ".github") +s.move(templated_files / ".github", excludes=["workflows/unittest.yml"]) s.move(templated_files / ".trampolinerc") python.py_samples(skip_readmes=True) diff --git a/pytest.ini b/pytest.ini index 985c255..9c2765b 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,3 +4,11 @@ filterwarnings = error # Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed ignore:.*custom tp_new.*in Python 3.14:DeprecationWarning + # Remove warning once https://github.com/googleapis/gapic-generator-python/issues/1939 is fixed + ignore:get_mtls_endpoint_and_cert_source is deprecated.:DeprecationWarning + # Remove warning once https://github.com/googleapis/gapic-generator-python/issues/2046 is fixed + ignore:coroutine 'AsyncMockMixin._execute_mock_call' was never awaited:RuntimeWarning + # Remove warning once https://github.com/grpc/grpc/issues/35974 is fixed + ignore:unclosed:ResourceWarning + # Remove after support for Python 3.7 is dropped + ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning diff --git a/setup.py b/setup.py index 1da010e..6c8183c 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ dependencies = [ "grpcio>=1.44.0, <2.0.0dev", "googleapis-common-protos[grpc]>=1.56.0, <2.0.0dev", - "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + "protobuf>=3.20.2,<6.0.0dev,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.7-python-pubsub.txt b/testing/constraints-3.7-python-pubsub.txt new file mode 100644 index 0000000..87ee8c9 --- /dev/null +++ b/testing/constraints-3.7-python-pubsub.txt @@ -0,0 +1,9 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +protobuf==3.20.2 +grpcio==1.51.3 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index e69de29..53e10d1 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -0,0 +1,9 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +protobuf==3.20.2 +grpcio==1.44.0 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index e69de29..cd4b4b0 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -0,0 +1,9 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +protobuf==4.21.6 +grpcio==1.44.0 diff --git a/testing/constraints-3.9-python-pubsub.txt b/testing/constraints-3.9-python-pubsub.txt new file mode 100644 index 0000000..e69de29