Skip to content

Commit

Permalink
Merge pull request #77 from singer-io/fix/treat-empty-object-schema-a…
Browse files Browse the repository at this point in the history
…s-all

Treat empty object schemas as 'all'
  • Loading branch information
dmosorast committed Oct 2, 2018
2 parents dfad8fc + 42b1d6b commit f004f5f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions singer/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from singer.schema import Schema

# pylint: disable=too-many-instance-attributes
class CatalogEntry(object):
class CatalogEntry():

def __init__(self, tap_stream_id=None, stream=None,
key_properties=None, schema=None, replication_key=None,
Expand Down Expand Up @@ -65,7 +65,7 @@ def to_dict(self):
return result


class Catalog(object):
class Catalog():

def __init__(self, streams):
self.streams = streams
Expand Down
2 changes: 1 addition & 1 deletion singer/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import singer.utils as u

class Message(object):
class Message():
'''Base class for messages.'''

def asdict(self): # pylint: disable=no-self-use
Expand Down
4 changes: 2 additions & 2 deletions singer/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def log(logger, point):
logger.info('METRIC: %s', json.dumps(result))


class Counter(object):
class Counter():
'''Increments a counter metric.
When you use Counter as a context manager, it will automatically emit
Expand Down Expand Up @@ -143,7 +143,7 @@ def _ready_to_log(self):
return time.time() - self.last_log_time > self.log_interval


class Timer(object): # pylint: disable=too-few-public-methods
class Timer(): # pylint: disable=too-few-public-methods
'''Produces metrics about the duration of operations.
You use a Timer as a context manager wrapping around some operation.
Expand Down
5 changes: 3 additions & 2 deletions singer/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]


class Schema(object): # pylint: disable=too-many-instance-attributes
class Schema(): # pylint: disable=too-many-instance-attributes
'''Object model for JSON Schema.
Tap and Target authors may find this to be more convenient than
Expand All @@ -34,7 +34,8 @@ class Schema(object): # pylint: disable=too-many-instance-attributes
def __init__(self, type=None, format=None, properties=None, items=None,
selected=None, inclusion=None, description=None, minimum=None,
maximum=None, exclusiveMinimum=None, exclusiveMaximum=None,
multipleOf=None, maxLength=None, minLength=None, additionalProperties=None, anyOf=None):
multipleOf=None, maxLength=None, minLength=None, additionalProperties=None,
anyOf=None):

self.type = type
self.properties = properties
Expand Down
6 changes: 5 additions & 1 deletion singer/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ def _transform_object(self, data, schema, path):
if not isinstance(data, dict):
return False, data

# Don't touch an empty schema
if schema == {}:
return True, data

result = {}
successes = []
for key, value in data.items():
Expand Down Expand Up @@ -240,7 +244,7 @@ def _transform(self, data, typ, schema, path):
return self._transform_array(data, schema["items"], path)

elif typ == "string":
if data != None:
if data is not None:
try:
return True, str(data)
except:
Expand Down

0 comments on commit f004f5f

Please sign in to comment.