GitHub
08/12/2026, 3:25 PMdatetime.datetime to str), but not from strings to their expected schema type? Is/should it be the responsibility of the developer to define this mapping?
sdk/singer_sdk/helpers/_typing.py
Lines 521 to 547 in</meltano/sdk/commit/c152403ba539a11d0d2b4a699c0885b31d4c7567|c152403>
| def _conform_primitive_property( # noqa: PLR0911 |
| -------------------------------------------------------------------------------- |
| elem: t.Any, # noqa: ANN401 |
| property_schema: dict, |
| ) -> t.Any: # noqa: ANN401 |
| """Converts a primitive (i.e. not object or array) to a json compatible type.""" |
| if isinstance(elem, (datetime.datetime,)): |
| return to_json_compatible(elem) |
| if isinstance(elem, datetime.date): |
| return elem.isoformat() |
| if isinstance(elem, datetime.timedelta): |
| epoch = datetime.datetime.fromtimestamp(0, UTC) |
| timedelta_from_epoch = epoch + elem |
| if timedelta_from_epoch.tzinfo is None: |
| timedelta_from_epoch = timedelta_from_epoch.replace(tzinfo=UTC) |
| return timedelta_from_epoch.isoformat() |
| if isinstance(elem, datetime.time): |
| return str(elem) |
| if isinstance(elem, bytes): |
| # for BIT value, treat 0 as False and anything else as True |
| return elem != b"\x00" if is_boolean_type(property_schema) else elem.hex() |
| if isinstance(elem, (float, decimal.Decimal)): |
| if math.isnan(elem) or math.isinf(elem): |
| return None |
| return elem |
| if _is_exclusive_boolean_type(property_schema): |
| return None if elem is None else elem != 0 |
| return elem |
i.e.
if isinstance(elem, str) and th.IntegerType.__type_name__ in property_schema["type"]:
return int(elem)
meltano/sdkGitHub
08/12/2026, 3:25 PM