Skip to content

Commit 2fe57c1

Browse files
lukesneeringerlandrito
authored andcommitted
BigQuery: Remove client-side enum validation. (googleapis#3735)
1 parent cf64a12 commit 2fe57c1

File tree

3 files changed

+1
-21
lines changed

3 files changed

+1
-21
lines changed

bigquery/google/cloud/bigquery/_helpers.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,19 +306,9 @@ def _validate(self, value):
306306
class _EnumProperty(_ConfigurationProperty):
307307
"""Pseudo-enumeration class.
308308
309-
Subclasses must define ``ALLOWED`` as a class-level constant: it must
310-
be a sequence of strings.
311-
312309
:type name: str
313310
:param name: name of the property.
314311
"""
315-
def _validate(self, value):
316-
"""Check that ``value`` is one of the allowed values.
317-
318-
:raises: ValueError if value is not allowed.
319-
"""
320-
if value not in self.ALLOWED:
321-
raise ValueError('Pass one of: %s' % ', '.join(self.ALLOWED))
322312

323313

324314
class UDFResource(object):

bigquery/google/cloud/bigquery/job.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,31 @@ class Compression(_EnumProperty):
9898
"""Pseudo-enum for ``compression`` properties."""
9999
GZIP = 'GZIP'
100100
NONE = 'NONE'
101-
ALLOWED = (GZIP, NONE)
102101

103102

104103
class CreateDisposition(_EnumProperty):
105104
"""Pseudo-enum for ``create_disposition`` properties."""
106105
CREATE_IF_NEEDED = 'CREATE_IF_NEEDED'
107106
CREATE_NEVER = 'CREATE_NEVER'
108-
ALLOWED = (CREATE_IF_NEEDED, CREATE_NEVER)
109107

110108

111109
class DestinationFormat(_EnumProperty):
112110
"""Pseudo-enum for ``destination_format`` properties."""
113111
CSV = 'CSV'
114112
NEWLINE_DELIMITED_JSON = 'NEWLINE_DELIMITED_JSON'
115113
AVRO = 'AVRO'
116-
ALLOWED = (CSV, NEWLINE_DELIMITED_JSON, AVRO)
117114

118115

119116
class Encoding(_EnumProperty):
120117
"""Pseudo-enum for ``encoding`` properties."""
121118
UTF_8 = 'UTF-8'
122119
ISO_8559_1 = 'ISO-8559-1'
123-
ALLOWED = (UTF_8, ISO_8559_1)
124120

125121

126122
class QueryPriority(_EnumProperty):
127123
"""Pseudo-enum for ``QueryJob.priority`` property."""
128124
INTERACTIVE = 'INTERACTIVE'
129125
BATCH = 'BATCH'
130-
ALLOWED = (INTERACTIVE, BATCH)
131126

132127

133128
class SourceFormat(_EnumProperty):
@@ -136,15 +131,13 @@ class SourceFormat(_EnumProperty):
136131
DATASTORE_BACKUP = 'DATASTORE_BACKUP'
137132
NEWLINE_DELIMITED_JSON = 'NEWLINE_DELIMITED_JSON'
138133
AVRO = 'AVRO'
139-
ALLOWED = (CSV, DATASTORE_BACKUP, NEWLINE_DELIMITED_JSON, AVRO)
140134

141135

142136
class WriteDisposition(_EnumProperty):
143137
"""Pseudo-enum for ``write_disposition`` properties."""
144138
WRITE_APPEND = 'WRITE_APPEND'
145139
WRITE_TRUNCATE = 'WRITE_TRUNCATE'
146140
WRITE_EMPTY = 'WRITE_EMPTY'
147-
ALLOWED = (WRITE_APPEND, WRITE_TRUNCATE, WRITE_EMPTY)
148141

149142

150143
class _AsyncJob(google.cloud.future.polling.PollingFuture):

bigquery/tests/unit/test__helpers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ def _get_target_class():
765765
def test_it(self):
766766

767767
class Sub(self._get_target_class()):
768-
ALLOWED = ('FOO', 'BAR', 'BAZ')
768+
pass
769769

770770
class Configuration(object):
771771
_attr = None
@@ -777,9 +777,6 @@ def __init__(self):
777777
self._configuration = Configuration()
778778

779779
wrapper = Wrapper()
780-
with self.assertRaises(ValueError):
781-
wrapper.attr = 'BOGUS'
782-
783780
wrapper.attr = 'FOO'
784781
self.assertEqual(wrapper.attr, 'FOO')
785782
self.assertEqual(wrapper._configuration._attr, 'FOO')

0 commit comments

Comments
 (0)