Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strictly enforce the ordering of type checking for integer vs number #35

Merged
merged 3 commits into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions tap_s3_csv/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

LOGGER = singer.get_logger()


#pylint: disable=too-many-return-statements
def infer(key, datum, date_overrides, check_second_call=False):
"""
Returns the inferred data type
"""

data_type_list = {int: 'integer', float: 'number'}

if datum is None or datum == '':
return None

Expand All @@ -32,12 +29,16 @@ def infer(key, datum, date_overrides, check_second_call=False):
if isinstance(datum, dict):
return 'dict'

for datatype in data_type_list:
try:
datatype(str(datum))
return data_type_list[datatype]
except (ValueError, TypeError):
pass
try:
int(str(datum))
return 'integer'
except (ValueError, TypeError):
pass
try:
float(str(datum))
return 'number'
except (ValueError, TypeError):
pass

except (ValueError, TypeError):
pass
Expand Down