From 444ea173147534e8c03b44eaf55c29f7bc026c8c Mon Sep 17 00:00:00 2001 From: iory Date: Sat, 18 Apr 2020 18:24:57 +0900 Subject: [PATCH] Refactor the timedelta_isoformat --- pysnooper/pycompat.py | 7 ++----- pysnooper/tracer.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pysnooper/pycompat.py b/pysnooper/pycompat.py index 1899ff8..c6b23b3 100644 --- a/pysnooper/pycompat.py +++ b/pysnooper/pycompat.py @@ -90,9 +90,6 @@ else: return datetime_module.time(hour, minute, second, microsecond) -def timedelta_isoformat(timedelta, timespec='microseconds'): - assert isinstance(timedelta, datetime_module.timedelta) - if timespec != 'microseconds': - raise NotImplementedError +def timedelta_isoformat(timedelta): time = (datetime_module.datetime.min + timedelta).time() - return time_isoformat(time, timespec) + return time_isoformat(time) diff --git a/pysnooper/tracer.py b/pysnooper/tracer.py index c7d6e49..1c9103b 100644 --- a/pysnooper/tracer.py +++ b/pysnooper/tracer.py @@ -368,7 +368,7 @@ class Tracer: if self.elapsed_time: duration = datetime_module.datetime.now() - self.start_times[-1] now_string = pycompat.timedelta_isoformat( - duration, timespec='microseconds') if not self.normalize else ' ' * 15 + duration) if not self.normalize else ' ' * 15 else: now = datetime_module.datetime.now().time() now_string = pycompat.time_isoformat(now, timespec='microseconds') if not self.normalize else ' ' * 15