Skip to content

Commit bd7fd85

Browse files
committed
Update HTTP annotation response router.
1 parent 9d40edb commit bd7fd85

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

vision/google/cloud/vision/annotations.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Annotations management for Vision API responses."""
1616

17+
import six
1718

1819
from google.cloud.vision.color import ImagePropertiesAnnotation
1920
from google.cloud.vision.entity import EntityAnnotation
@@ -86,14 +87,11 @@ def from_api_repr(cls, response):
8687
:rtype: :class:`~google.cloud.vision.annotations.Annotations`
8788
:returns: An instance of ``Annotations`` with detection types loaded.
8889
"""
89-
annotations = {}
90-
for feature_type, annotation in response.items():
91-
curr_feature = annotations.setdefault(_KEY_MAP[feature_type], [])
92-
entity = _entity_from_response_type(feature_type, annotation)
93-
if isinstance(entity, list):
94-
curr_feature.extend(entity)
95-
else:
96-
annotations[_KEY_MAP[feature_type]] = entity
90+
annotations = {
91+
_KEY_MAP[feature_type]: _entity_from_response_type(
92+
feature_type, annotation)
93+
for feature_type, annotation in six.iteritems(response)
94+
}
9795
return cls(**annotations)
9896

9997
@classmethod

0 commit comments

Comments
 (0)