-
Notifications
You must be signed in to change notification settings - Fork 79
fix: improve type checking #2530
Changes from 9 commits
8ea95e9
e42c823
7847002
e476732
3cb8e92
7680213
b8e99f4
75748ee
0118aaf
fb5f0cb
7189985
ffd53ad
4e8a7a6
6664f75
f394d57
7b7c8dc
96f14a3
7264e63
cbe19db
3920092
681e626
10007c2
1a3afcd
51b2253
b50adfc
c98f2f0
e5ee739
06b2000
de47a24
89964fc
0354666
665c7c8
7f6c4ac
8d236ca
0fd2443
6077c20
eb825b3
610541d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| {% if "ListOperations" in api.mixin_api_methods %} | ||
| def list_operations( | ||
| self, | ||
| request: Optional[operations_pb2.ListOperationsRequest] = None, | ||
| request: Optional[Union[operations_pb2.ListOperationsRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -26,6 +26,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = operations_pb2.ListOperationsRequest(**request) | ||
|
|
||
|
|
@@ -59,7 +61,7 @@ | |
| {% if "GetOperation" in api.mixin_api_methods %} | ||
| def get_operation( | ||
| self, | ||
| request: Optional[operations_pb2.GetOperationRequest] = None, | ||
| request: Optional[Union[operations_pb2.GetOperationRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -82,6 +84,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = operations_pb2.GetOperationRequest(**request) | ||
|
|
||
|
|
@@ -114,7 +118,7 @@ | |
| {% if "DeleteOperation" in api.mixin_api_methods %} | ||
| def delete_operation( | ||
| self, | ||
| request: Optional[operations_pb2.DeleteOperationRequest] = None, | ||
| request: Optional[Union[operations_pb2.DeleteOperationRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -141,6 +145,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = operations_pb2.DeleteOperationRequest(**request) | ||
|
|
||
|
|
@@ -165,7 +171,7 @@ | |
| {% if "CancelOperation" in api.mixin_api_methods %} | ||
| def cancel_operation( | ||
| self, | ||
| request: Optional[operations_pb2.CancelOperationRequest] = None, | ||
| request: Optional[Union[operations_pb2.CancelOperationRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -191,6 +197,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = operations_pb2.CancelOperationRequest(**request) | ||
|
|
||
|
|
@@ -215,7 +223,7 @@ | |
| {% if "WaitOperation" in api.mixin_api_methods %} | ||
| def wait_operation( | ||
| self, | ||
| request: Optional[operations_pb2.WaitOperationRequest] = None, | ||
| request: Optional[Union[operations_pb2.WaitOperationRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -244,6 +252,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = operations_pb2.WaitOperationRequest(**request) | ||
|
|
||
|
|
@@ -281,7 +291,7 @@ | |
| {% if "SetIamPolicy" in api.mixin_api_methods %} | ||
| def set_iam_policy( | ||
| self, | ||
| request: Optional[iam_policy_pb2.SetIamPolicyRequest] = None, | ||
| request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -370,6 +380,8 @@ | |
|
|
||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = iam_policy_pb2.SetIamPolicyRequest(**request) | ||
|
|
||
|
|
@@ -402,7 +414,7 @@ | |
| {% if "GetIamPolicy" in api.mixin_api_methods %} | ||
| def get_iam_policy( | ||
| self, | ||
| request: Optional[iam_policy_pb2.GetIamPolicyRequest] = None, | ||
| request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -492,6 +504,8 @@ | |
|
|
||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = iam_policy_pb2.GetIamPolicyRequest(**request) | ||
|
|
||
|
|
@@ -524,7 +538,7 @@ | |
| {% if "TestIamPermissions" in api.mixin_api_methods %} | ||
| def test_iam_permissions( | ||
| self, | ||
| request: Optional[iam_policy_pb2.TestIamPermissionsRequest] = None, | ||
| request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -552,6 +566,8 @@ | |
|
|
||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = iam_policy_pb2.TestIamPermissionsRequest(**request) | ||
|
|
||
|
|
@@ -588,7 +604,7 @@ | |
| {% if "GetLocation" in api.mixin_api_methods %} | ||
| def get_location( | ||
| self, | ||
| request: Optional[locations_pb2.GetLocationRequest] = None, | ||
| request: Optional[Union[locations_pb2.GetLocationRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -611,6 +627,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = locations_pb2.GetLocationRequest(**request) | ||
|
|
||
|
|
@@ -643,7 +661,7 @@ | |
| {% if "ListLocations" in api.mixin_api_methods %} | ||
| def list_locations( | ||
| self, | ||
| request: Optional[locations_pb2.ListLocationsRequest] = None, | ||
| request: Optional[Union[locations_pb2.ListLocationsRequest, dict] = None, | ||
| *, | ||
| retry: OptionalRetry = gapic_v1.method.DEFAULT, | ||
| timeout: Union[float, object] = gapic_v1.method.DEFAULT, | ||
|
|
@@ -666,6 +684,8 @@ | |
| # Create or coerce a protobuf request object. | ||
| # The request isn't a proto-plus wrapped type, | ||
| # so it must be constructed via keyword expansion. | ||
| if request is None: | ||
| request = {} | ||
|
||
| if isinstance(request, dict): | ||
| request = locations_pb2.ListLocationsRequest(**request) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,8 +91,7 @@ nox.options.error_on_missing_interpreters = True | |
| def mypy(session): | ||
| """Run the type checker.""" | ||
| session.install( | ||
| # TODO(https://github.com/googleapis/gapic-generator-python/issues/2410): Use the latest version of mypy | ||
| "mypy<1.16.0", | ||
| "mypy", | ||
| "types-requests", | ||
| "types-protobuf", | ||
| ) | ||
|
|
@@ -105,6 +104,8 @@ def mypy(session): | |
| {% else %} | ||
| "{{ api.naming.versioned_module_name }}", | ||
| {% endif %} | ||
| "--check-untyped-defs", | ||
| *session.posargs, | ||
|
Comment on lines
+104
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ) | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.