Skip to content

Commit 341f448

Browse files
authored
fix: guard assignments of certain values against None (#220)
* chore: manual regen of synth * cleanup
1 parent bdd6a4e commit 341f448

File tree

8 files changed

+73
-23
lines changed

8 files changed

+73
-23
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ docs.metadata
5050

5151
# Virtual environment
5252
env/
53+
54+
# Test logs
5355
coverage.xml
54-
sponge_log.xml
56+
*sponge_log.xml
5557

5658
# System test environment variables.
5759
system_tests/local_test_setup

.kokoro/build.sh

+10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
4040
python3 -m pip install --upgrade --quiet nox
4141
python3 -m nox --version
4242

43+
# If this is a continuous build, send the test log to the FlakyBot.
44+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
45+
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
46+
cleanup() {
47+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
48+
$KOKORO_GFILE_DIR/linux_amd64/flakybot
49+
}
50+
trap cleanup EXIT HUP
51+
fi
52+
4353
# If NOX_SESSION is set, it only runs the specified session,
4454
# otherwise run all the sessions.
4555
if [[ -n "${NOX_SESSION:-}" ]]; then

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,8 @@ def create_instance(
484484
request.instance_id = instance_id
485485
if instance is not None:
486486
request.instance = instance
487-
488-
if clusters:
489-
request.clusters.update(clusters)
487+
if clusters is not None:
488+
request.clusters = clusters
490489

491490
# Wrap the RPC method; this adds retry and timeout information,
492491
# and friendly error handling.
@@ -1832,6 +1831,9 @@ def get_iam_policy(
18321831
elif not request:
18331832
request = iam_policy.GetIamPolicyRequest(resource=resource,)
18341833

1834+
if resource is not None:
1835+
request.resource = resource
1836+
18351837
# Wrap the RPC method; this adds retry and timeout information,
18361838
# and friendly error handling.
18371839
rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
@@ -1957,6 +1959,9 @@ def set_iam_policy(
19571959
elif not request:
19581960
request = iam_policy.SetIamPolicyRequest(resource=resource,)
19591961

1962+
if resource is not None:
1963+
request.resource = resource
1964+
19601965
# Wrap the RPC method; this adds retry and timeout information,
19611966
# and friendly error handling.
19621967
rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
@@ -2039,6 +2044,9 @@ def test_iam_permissions(
20392044
resource=resource, permissions=permissions,
20402045
)
20412046

2047+
if resource is not None:
2048+
request.resource = resource
2049+
20422050
# Wrap the RPC method; this adds retry and timeout information,
20432051
# and friendly error handling.
20442052
rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]

google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/pagers.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515
# limitations under the License.
1616
#
1717

18-
from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
18+
from typing import (
19+
Any,
20+
AsyncIterable,
21+
Awaitable,
22+
Callable,
23+
Iterable,
24+
Sequence,
25+
Tuple,
26+
Optional,
27+
)
1928

2029
from google.cloud.bigtable_admin_v2.types import bigtable_instance_admin
2130
from google.cloud.bigtable_admin_v2.types import instance

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,8 @@ def modify_column_families(
952952

953953
if name is not None:
954954
request.name = name
955-
956-
if modifications:
957-
request.modifications.extend(modifications)
955+
if modifications is not None:
956+
request.modifications = modifications
958957

959958
# Wrap the RPC method; this adds retry and timeout information,
960959
# and friendly error handling.
@@ -2236,6 +2235,9 @@ def get_iam_policy(
22362235
elif not request:
22372236
request = iam_policy.GetIamPolicyRequest(resource=resource,)
22382237

2238+
if resource is not None:
2239+
request.resource = resource
2240+
22392241
# Wrap the RPC method; this adds retry and timeout information,
22402242
# and friendly error handling.
22412243
rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
@@ -2361,6 +2363,9 @@ def set_iam_policy(
23612363
elif not request:
23622364
request = iam_policy.SetIamPolicyRequest(resource=resource,)
23632365

2366+
if resource is not None:
2367+
request.resource = resource
2368+
23642369
# Wrap the RPC method; this adds retry and timeout information,
23652370
# and friendly error handling.
23662371
rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
@@ -2443,6 +2448,9 @@ def test_iam_permissions(
24432448
resource=resource, permissions=permissions,
24442449
)
24452450

2451+
if resource is not None:
2452+
request.resource = resource
2453+
24462454
# Wrap the RPC method; this adds retry and timeout information,
24472455
# and friendly error handling.
24482456
rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]

google/cloud/bigtable_admin_v2/services/bigtable_table_admin/pagers.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515
# limitations under the License.
1616
#
1717

18-
from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
18+
from typing import (
19+
Any,
20+
AsyncIterable,
21+
Awaitable,
22+
Callable,
23+
Iterable,
24+
Sequence,
25+
Tuple,
26+
Optional,
27+
)
1928

2029
from google.cloud.bigtable_admin_v2.types import bigtable_table_admin
2130
from google.cloud.bigtable_admin_v2.types import table

google/cloud/bigtable_v2/services/bigtable/client.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -621,12 +621,11 @@ def mutate_row(
621621
request.table_name = table_name
622622
if row_key is not None:
623623
request.row_key = row_key
624+
if mutations is not None:
625+
request.mutations = mutations
624626
if app_profile_id is not None:
625627
request.app_profile_id = app_profile_id
626628

627-
if mutations:
628-
request.mutations.extend(mutations)
629-
630629
# Wrap the RPC method; this adds retry and timeout information,
631630
# and friendly error handling.
632631
rpc = self._transport._wrapped_methods[self._transport.mutate_row]
@@ -730,12 +729,11 @@ def mutate_rows(
730729

731730
if table_name is not None:
732731
request.table_name = table_name
732+
if entries is not None:
733+
request.entries = entries
733734
if app_profile_id is not None:
734735
request.app_profile_id = app_profile_id
735736

736-
if entries:
737-
request.entries.extend(entries)
738-
739737
# Wrap the RPC method; this adds retry and timeout information,
740738
# and friendly error handling.
741739
rpc = self._transport._wrapped_methods[self._transport.mutate_rows]
@@ -881,14 +879,13 @@ def check_and_mutate_row(
881879
request.row_key = row_key
882880
if predicate_filter is not None:
883881
request.predicate_filter = predicate_filter
882+
if true_mutations is not None:
883+
request.true_mutations = true_mutations
884+
if false_mutations is not None:
885+
request.false_mutations = false_mutations
884886
if app_profile_id is not None:
885887
request.app_profile_id = app_profile_id
886888

887-
if true_mutations:
888-
request.true_mutations.extend(true_mutations)
889-
if false_mutations:
890-
request.false_mutations.extend(false_mutations)
891-
892889
# Wrap the RPC method; this adds retry and timeout information,
893890
# and friendly error handling.
894891
rpc = self._transport._wrapped_methods[self._transport.check_and_mutate_row]
@@ -1005,12 +1002,11 @@ def read_modify_write_row(
10051002
request.table_name = table_name
10061003
if row_key is not None:
10071004
request.row_key = row_key
1005+
if rules is not None:
1006+
request.rules = rules
10081007
if app_profile_id is not None:
10091008
request.app_profile_id = app_profile_id
10101009

1011-
if rules:
1012-
request.rules.extend(rules)
1013-
10141010
# Wrap the RPC method; this adds retry and timeout information,
10151011
# and friendly error handling.
10161012
rpc = self._transport._wrapped_methods[self._transport.read_modify_write_row]

synth.py

+8
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
s.move(library / "tests")
4848
s.move(library / "scripts")
4949

50+
# temporary workaround for https://github.com/googleapis/gapic-generator-python/issues/778
51+
s.replace(
52+
"google/cloud/**/client.py",
53+
"""\s+if permissions:
54+
\s+request\.permissions\.extend\(permissions\)""",
55+
"",
56+
)
57+
5058
# ----------------------------------------------------------------------------
5159
# Add templated files
5260
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)