From 9e12b53c3b36dcdbfe8a59cdeca95c86654f4e7f Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 19 Sep 2024 22:03:02 +0200 Subject: [PATCH] Trip.duration and Trip.real_time_duration are now nullable --- src/pyrmv/classes/trip.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pyrmv/classes/trip.py b/src/pyrmv/classes/trip.py index dd41494..e62c6dc 100644 --- a/src/pyrmv/classes/trip.py +++ b/src/pyrmv/classes/trip.py @@ -19,8 +19,10 @@ class Trip: self.index: int = data["idx"] self.id: str = data["tripId"] self.ctx_recon: str = data["ctxRecon"] - self.duration: Union[Duration, timedelta] = parse_duration(data["duration"]) - self.real_time_duration: Union[Duration, timedelta] = ( + self.duration: Union[Duration, timedelta, None] = ( + None if "duration" not in data else parse_duration(data["duration"]) + ) + self.real_time_duration: Union[Duration, timedelta, None] = ( None if "rtDuration" not in data else parse_duration(data["rtDuration"]) ) self.checksum: str = data["checksum"]