Skip to content

Commit

Permalink
Merge ee39caf into 88a05fb
Browse files Browse the repository at this point in the history
  • Loading branch information
tirkarthi committed Jan 27, 2020
2 parents 88a05fb + ee39caf commit a2f2325
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions apitools/base/py/extra_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@

"""Extra types understood by apitools."""

import collections
import datetime
import json
import numbers

import six

if six.PY3:
from collections.abc import Iterable
else:
from collections import Iterable

from apitools.base.protorpclite import message_types
from apitools.base.protorpclite import messages
from apitools.base.protorpclite import protojson
Expand Down Expand Up @@ -129,7 +133,7 @@ def _PythonValueToJsonValue(py_value):
return JsonValue(double_value=float(py_value))
if isinstance(py_value, dict):
return JsonValue(object_value=_PythonValueToJsonObject(py_value))
if isinstance(py_value, collections.Iterable):
if isinstance(py_value, Iterable):
return JsonValue(array_value=_PythonValueToJsonArray(py_value))
raise exceptions.InvalidDataError(
'Cannot convert "%s" to JsonValue' % py_value)
Expand Down Expand Up @@ -212,7 +216,7 @@ def _JsonProtoToPythonValue(json_proto):
def _PythonValueToJsonProto(py_value):
if isinstance(py_value, dict):
return _PythonValueToJsonObject(py_value)
if (isinstance(py_value, collections.Iterable) and
if (isinstance(py_value, Iterable) and
not isinstance(py_value, six.string_types)):
return _PythonValueToJsonArray(py_value)
return _PythonValueToJsonValue(py_value)
Expand Down
8 changes: 6 additions & 2 deletions apitools/base/py/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Assorted utilities shared between parts of apitools."""

import collections
import os
import random

Expand All @@ -26,6 +25,11 @@
import six.moves.urllib.parse as urllib_parse
import six.moves.urllib.request as urllib_request

if six.PY3:
from collections.abc import Iterable
else:
from collections import Iterable

from apitools.base.protorpclite import messages
from apitools.base.py import encoding_helper as encoding
from apitools.base.py import exceptions
Expand Down Expand Up @@ -78,7 +82,7 @@ def NormalizeScopes(scope_spec):
if isinstance(scope_spec, six.string_types):
scope_spec = six.ensure_str(scope_spec)
return set(scope_spec.split(' '))
elif isinstance(scope_spec, collections.Iterable):
elif isinstance(scope_spec, Iterable):
scope_spec = [six.ensure_str(x) for x in scope_spec]
return set(scope_spec)
raise exceptions.TypecheckError(
Expand Down

0 comments on commit a2f2325

Please sign in to comment.