Skip to content

Commit b29f859

Browse files
committed
Fix missed mypy error
1 parent d660e3c commit b29f859

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tests/test_common_parsers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ def test_jsonify_datetime_value(self):
312312
jdata = Parsers.jsonify_yaml_data(cdata)
313313
assert jdata == "2021-01-13T01:02:03"
314314

315+
def test_jsonify_datetime_value_date_only(self):
316+
cdata = dt.datetime(2021, 1, 13, 0, 0, 0)
317+
jdata = Parsers.jsonify_yaml_data(cdata)
318+
assert jdata == "2021-01-13"
319+
315320
def test_jsonify_commented_map_with_merge_tuple(self):
316321
yaml = Parsers.get_yaml_editor()
317322
cdata = yaml.load("""

yamlpath/common/parsers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,11 @@ def _jsonify_datetime_value(
396396
and data.microsecond == 0
397397
and getattr(data, "tzinfo", None) is None
398398
)
399-
return (
400-
data.date().isoformat()
401-
if is_date_only
402-
else Nodes.get_timestamp_with_tzinfo(data).isoformat()
403-
)
399+
if is_date_only:
400+
return data.date().isoformat()
401+
402+
tsdata = Nodes.get_timestamp_with_tzinfo(data)
403+
return str(tsdata.isoformat())
404404

405405
@staticmethod
406406
def _jsonify_seq_values(data: Any) -> Any:

0 commit comments

Comments
 (0)