Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: guard assignments of certain values against None #220

Merged
merged 2 commits into from Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -50,8 +50,10 @@ docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
sponge_log.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
10 changes: 10 additions & 0 deletions .kokoro/build.sh
Expand Up @@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
Expand Down
Expand Up @@ -484,9 +484,8 @@ def create_instance(
request.instance_id = instance_id
if instance is not None:
request.instance = instance

if clusters:
request.clusters.update(clusters)
if clusters is not None:
request.clusters = clusters

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

if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
Expand Down Expand Up @@ -1957,6 +1959,9 @@ def set_iam_policy(
elif not request:
request = iam_policy.SetIamPolicyRequest(resource=resource,)

if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
Expand Down Expand Up @@ -2039,6 +2044,9 @@ def test_iam_permissions(
resource=resource, permissions=permissions,
)

if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
Expand Down
Expand Up @@ -15,7 +15,16 @@
# limitations under the License.
#

from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
from typing import (
Any,
AsyncIterable,
Awaitable,
Callable,
Iterable,
Sequence,
Tuple,
Optional,
)

from google.cloud.bigtable_admin_v2.types import bigtable_instance_admin
from google.cloud.bigtable_admin_v2.types import instance
Expand Down
Expand Up @@ -952,9 +952,8 @@ def modify_column_families(

if name is not None:
request.name = name

if modifications:
request.modifications.extend(modifications)
if modifications is not None:
request.modifications = modifications

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

if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
Expand Down Expand Up @@ -2361,6 +2363,9 @@ def set_iam_policy(
elif not request:
request = iam_policy.SetIamPolicyRequest(resource=resource,)

if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
Expand Down Expand Up @@ -2443,6 +2448,9 @@ def test_iam_permissions(
resource=resource, permissions=permissions,
)

if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
Expand Down
Expand Up @@ -15,7 +15,16 @@
# limitations under the License.
#

from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
from typing import (
Any,
AsyncIterable,
Awaitable,
Callable,
Iterable,
Sequence,
Tuple,
Optional,
)

from google.cloud.bigtable_admin_v2.types import bigtable_table_admin
from google.cloud.bigtable_admin_v2.types import table
Expand Down
24 changes: 10 additions & 14 deletions google/cloud/bigtable_v2/services/bigtable/client.py
Expand Up @@ -621,12 +621,11 @@ def mutate_row(
request.table_name = table_name
if row_key is not None:
request.row_key = row_key
if mutations is not None:
request.mutations = mutations
if app_profile_id is not None:
request.app_profile_id = app_profile_id

if mutations:
request.mutations.extend(mutations)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.mutate_row]
Expand Down Expand Up @@ -730,12 +729,11 @@ def mutate_rows(

if table_name is not None:
request.table_name = table_name
if entries is not None:
request.entries = entries
if app_profile_id is not None:
request.app_profile_id = app_profile_id

if entries:
request.entries.extend(entries)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.mutate_rows]
Expand Down Expand Up @@ -881,14 +879,13 @@ def check_and_mutate_row(
request.row_key = row_key
if predicate_filter is not None:
request.predicate_filter = predicate_filter
if true_mutations is not None:
request.true_mutations = true_mutations
if false_mutations is not None:
request.false_mutations = false_mutations
if app_profile_id is not None:
request.app_profile_id = app_profile_id

if true_mutations:
request.true_mutations.extend(true_mutations)
if false_mutations:
request.false_mutations.extend(false_mutations)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.check_and_mutate_row]
Expand Down Expand Up @@ -1005,12 +1002,11 @@ def read_modify_write_row(
request.table_name = table_name
if row_key is not None:
request.row_key = row_key
if rules is not None:
request.rules = rules
if app_profile_id is not None:
request.app_profile_id = app_profile_id

if rules:
request.rules.extend(rules)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.read_modify_write_row]
Expand Down
8 changes: 8 additions & 0 deletions synth.py
Expand Up @@ -47,6 +47,14 @@
s.move(library / "tests")
s.move(library / "scripts")

# temporary workaround for https://github.com/googleapis/gapic-generator-python/issues/778
s.replace(
"google/cloud/**/client.py",
"""\s+if permissions:
\s+request\.permissions\.extend\(permissions\)""",
"",
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
Expand Down