Skip to content

Commit 2ba1362

Browse files
committed
Return condition directly
Instead of using: if condition: return True else: return False Use: return bool(condition)
1 parent 94d4e3a commit 2ba1362

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

khal/icalendar.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,7 @@ def sanitize_rrule(vevent):
469469

470470
def invalid_timezone(prop):
471471
"""check if an icalendar property has a timezone attached we don't understand"""
472-
if hasattr(prop.dt, 'tzinfo') and prop.dt.tzinfo is None and 'TZID' in prop.params:
473-
return True
474-
else:
475-
return False
472+
return bool(hasattr(prop.dt, 'tzinfo') and prop.dt.tzinfo is None and 'TZID' in prop.params)
476473

477474

478475
def _get_all_properties(vevent, prop):

khal/ui/calendarwidget.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ def reset_styles(self, focus: bool=False) -> None:
110110

111111
@property
112112
def marked(self) -> bool:
113-
if 'mark' in [self.halves[0].attr_map[None], self.halves[1].attr_map[None]]:
114-
return True
115-
else:
116-
return False
113+
return 'mark' in [self.halves[0].attr_map[None], self.halves[1].attr_map[None]]
117114

118115
@classmethod
119116
def selectable(cls) -> bool:

khal/utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,7 @@ def to_naive_utc(dtime: dt.datetime) -> dt.datetime:
151151

152152
def is_aware(dtime: dt.datetime) -> bool:
153153
"""test if a datetime instance is timezone aware"""
154-
if dtime.tzinfo is not None and dtime.tzinfo.utcoffset(dtime) is not None:
155-
return True
156-
else:
157-
return False
154+
return bool(dtime.tzinfo is not None and dtime.tzinfo.utcoffset(dtime) is not None)
158155

159156

160157
def relative_timedelta_str(day: dt.date) -> str:

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def coll_vdirs(tmpdir) -> CollVdirType:
4848
for name in example_cals:
4949
path = str(tmpdir) + '/' + name
5050
os.makedirs(path, mode=0o770)
51-
readonly = True if name == 'a_calendar' else False
51+
readonly = name == 'a_calendar'
5252
calendars[name] = CalendarConfiguration(
5353
name=name,
5454
path=path,
@@ -70,7 +70,7 @@ def coll_vdirs_birthday(tmpdir):
7070
for name in example_cals:
7171
path = str(tmpdir) + '/' + name
7272
os.makedirs(path, mode=0o770)
73-
readonly = True if name == 'a_calendar' else False
73+
readonly = name == 'a_calendar'
7474
calendars[name] = {'name': name, 'path': path, 'color': 'dark blue',
7575
'readonly': readonly, 'unicode_symbols': True, 'ctype': 'birthdays',
7676
'addresses': '[email protected]'}

0 commit comments

Comments
 (0)