From 3a250ad9375fd12fba7a2543b454c040888631c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20BAPTISTE?= Date: Mon, 25 May 2020 13:57:56 +0200 Subject: [PATCH] fix: Call repr for non built-in type objects only --- google/cloud/bigquery/table.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/google/cloud/bigquery/table.py b/google/cloud/bigquery/table.py index cbd0d2ee6..ced8c3da1 100644 --- a/google/cloud/bigquery/table.py +++ b/google/cloud/bigquery/table.py @@ -2128,9 +2128,14 @@ def to_api_repr(self): return self._properties def _key(self): + # because we are only "renaming" top level keys shallow copy is sufficient here. properties = self._properties.copy() if "type" in properties.keys(): - properties["type_"] = properties.pop("type") + # calling repr for non built-in type objects. + properties["type_"] = repr(properties.pop("type")) + if "field" in properties.keys(): + # calling repr for non built-in type objects. + properties["field"] = repr(properties["field"]) if "requirePartitionFilter" in properties.keys(): properties["require_partition_filter"] = properties.pop("requirePartitionFilter") if "expirationMs" in properties.keys(): @@ -2149,7 +2154,7 @@ def __hash__(self): return hash(self._key()) def __repr__(self): - key_vals = ["{}={}".format(key, repr(val)) for key, val in self._key()] + key_vals = ["{}={}".format(key, val) for key, val in self._key()] return "TimePartitioning({})".format(",".join(key_vals))