From 36ce3951c63d24a73bf63536ebec7bfa60a23044 Mon Sep 17 00:00:00 2001 From: M Sai Kiran <116418856+MSaiKiran9@users.noreply.github.com> Date: Mon, 9 Oct 2023 21:01:18 +0530 Subject: [PATCH] rev2 --- python/datetime.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/datetime.py b/python/datetime.py index 3e94ecd7..96c4cfdf 100644 --- a/python/datetime.py +++ b/python/datetime.py @@ -11,8 +11,8 @@ class timedelta: return f"datetime.timedelta({self.days}, {self.seconds})" def check(self, other, class_type): - if not isinstance(other, class_type): - raise NotImplementedError("incompatible types / not implemented") + if type(other) is not class_type: + return NotImplemented def __eq__(self, other: 'timedelta') -> bool: self.check(other, timedelta) @@ -55,8 +55,8 @@ class date: return date(t.tm_year, t.tm_mon, t.tm_mday) def check(self, other, class_type): - if not isinstance(other, class_type): - raise NotImplementedError("incompatible types / not implemented") + if type(other) is not class_type: + return NotImplemented def __eq__(self, other: 'date') -> bool: self.check(other, date) @@ -106,8 +106,8 @@ class datetime(date): return datetime(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec) def check(self, other, class_type): - if not isinstance(other, class_type): - raise NotImplementedError("incompatible types / not implemented") + if type(other) is not class_type: + return NotImplemented def __str__(self): return f"{self.year}-{self.month:02}-{self.day:02} {self.hour:02}:{self.minute:02}:{self.second:02}"