Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions crates/target_python/output/basic_discriminator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/basic_enum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/basic_properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/custom_overrides/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/description/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/enum_collisions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/geojson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/initialisms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/keywords/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/nullable_elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/nullable_enum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/nullable_properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/nullable_references/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/optional_properties/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/reference/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_boolean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_empty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_float32/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_float64/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_int16/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_int32/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_int8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_nullable_string/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_string/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_timestamp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_uint16/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_uint32/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/root_uint8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/type_collisions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/output/values/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _to_json_data(data: Any) -> Any:
if data is None or type(data) in [bool, int, float, str, object]:
return data
if type(data) is datetime:
if data.tzinfo == None:
return data.replace(tzinfo=timezone.utc).isoformat()
return data.isoformat()
if type(data) is list:
return [_to_json_data(d) for d in data]
Expand Down
2 changes: 2 additions & 0 deletions crates/target_python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ impl jtd_codegen::target::Target for Target {
)?;
writeln!(out, " return data")?;
writeln!(out, " if type(data) is datetime:")?;
writeln!(out, " if data.tzinfo == None:")?;
writeln!(out, " return data.replace(tzinfo=timezone.utc).isoformat()")?;
writeln!(out, " return data.isoformat()")?;
writeln!(out, " if type(data) is list:")?;
writeln!(out, " return [_to_json_data(d) for d in data]")?;
Expand Down