Skip to content

Commit e22fab2

Browse files
committed
Use is to compare types
1 parent 1b6e3f9 commit e22fab2

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

khal/icalendar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ def sanitize_datetime(date: dt.date) -> dt.date:
289289
# rrule._until and dtstart could be dt.date or dt.datetime. They
290290
# need to be the same for comparison
291291
testuntil = rrule._until # type: ignore
292-
if (type(dtstart) == dt.date and type(testuntil) == dt.datetime):
292+
if (type(dtstart) is dt.date and type(testuntil) is dt.datetime):
293293
testuntil = testuntil.date()
294294
teststart = dtstart
295-
if (type(testuntil) == dt.date and type(teststart) == dt.datetime):
295+
if (type(testuntil) is dt.date and type(teststart) is dt.datetime):
296296
teststart = teststart.date()
297297

298298
if testuntil < teststart:
@@ -430,7 +430,7 @@ def sanitize_timerange(dtstart, dtend, duration=None):
430430
"Assuming it's the same timezone as the end time"
431431
)
432432
dtstart = dtend.tzinfo.localize(dtstart)
433-
if dtend is not None and type(dtstart) != type(dtend):
433+
if dtend is not None and type(dtstart) is not type(dtend):
434434
raise ValueError(
435435
'The event\'s end time (DTEND) and start time (DTSTART) are not of the same type.')
436436

khal/khalendar/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def update_start_end(self, start: dt.datetime, end: dt.datetime) -> None:
211211
212212
beware, this methods performs some open heart surgery
213213
"""
214-
if type(start) != type(end):
214+
if type(start) is not type(end):
215215
raise ValueError('DTSTART and DTEND should be of the same type (datetime or date)')
216216
self.__class__ = self._get_type_from_date(start)
217217

tests/event_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def test_event_raw_UTC():
413413
def test_zulu_events():
414414
"""test if events in Zulu time are correctly recognized as localized events"""
415415
event = Event.fromString(_get_text('event_dt_simple_zulu'), **EVENT_KWARGS)
416-
assert type(event) == LocalizedEvent
416+
assert type(event) is LocalizedEvent
417417
assert event.start_local == BERLIN.localize(dt.datetime(2014, 4, 9, 11, 30))
418418

419419

@@ -451,9 +451,9 @@ def test_recur():
451451

452452
def test_type_inference():
453453
event = Event.fromString(_get_text('event_dt_simple'), **EVENT_KWARGS)
454-
assert type(event) == LocalizedEvent
454+
assert type(event) is LocalizedEvent
455455
event = Event.fromString(_get_text('event_dt_simple_zulu'), **EVENT_KWARGS)
456-
assert type(event) == LocalizedEvent
456+
assert type(event) is LocalizedEvent
457457

458458

459459
def test_duplicate_event():

0 commit comments

Comments
 (0)