diff options
author | Hugo Osvaldo Barrera <hugo@whynothugo.nl> | 2023-06-06 11:54:47 +0200 |
---|---|---|
committer | Hugo Osvaldo Barrera <hugo@whynothugo.nl> | 2023-06-06 12:22:49 +0200 |
commit | c345640cadc5ffcebb78f53daebd0b39885791a8 (patch) | |
tree | ff4c71ab642b12bd7341de37d5528bbe1e66c5da | |
parent | 9509967dcb6e734915f7c7073a4cc183159e96fb (diff) |
Return condition directly
Instead of using:
if condition:
return True
else:
return False
Use:
return condition
-rw-r--r-- | khal/icalendar.py | 10 | ||||
-rw-r--r-- | khal/ui/calendarwidget.py | 5 | ||||
-rw-r--r-- | khal/utils.py | 5 | ||||
-rw-r--r-- | tests/conftest.py | 4 |
4 files changed, 6 insertions, 18 deletions
diff --git a/khal/icalendar.py b/khal/icalendar.py index 5ae17874..bb0f2799 100644 --- a/khal/icalendar.py +++ b/khal/icalendar.py @@ -356,10 +356,7 @@ def assert_only_one_uid(cal: icalendar.Calendar): for item in cal.walk(): if item.name == 'VEVENT': uids.add(item['UID']) - if len(uids) > 1: - return False - else: - return True + return len(uids) <= 1 def sanitize(vevent, default_timezone, href='', calendar=''): @@ -468,10 +465,7 @@ def sanitize_rrule(vevent): def invalid_timezone(prop): """check if an icalendar property has a timezone attached we don't understand""" - if hasattr(prop.dt, 'tzinfo') and prop.dt.tzinfo is None and 'TZID' in prop.params: - return True - else: - return False + return bool(hasattr(prop.dt, 'tzinfo') and prop.dt.tzinfo is None and 'TZID' in prop.params) def _get_all_properties(vevent, prop): diff --git a/khal/ui/calendarwidget.py b/khal/ui/calendarwidget.py index fe911dd0..62678209 100644 --- a/khal/ui/calendarwidget.py +++ b/khal/ui/calendarwidget.py @@ -103,10 +103,7 @@ class Date(urwid.WidgetWrap): @property def marked(self): - if 'mark' in [self.halves[0].attr_map[None], self.halves[1].attr_map[None]]: - return True - else: - return False + return 'mark' in [self.halves[0].attr_map[None], self.halves[1].attr_map[None]] @classmethod def selectable(cls): diff --git a/khal/utils.py b/khal/utils.py index 30ba2125..ad83b73f 100644 --- a/khal/utils.py +++ b/khal/utils.py @@ -143,10 +143,7 @@ def to_naive_utc(dtime: dt.datetime) -> dt.datetime: def is_aware(dtime: dt.datetime) -> bool: """test if a datetime instance is timezone aware""" - if dtime.tzinfo is not None and dtime.tzinfo.utcoffset(dtime) is not None: - return True - else: - return False + return bool(dtime.tzinfo is not None and dtime.tzinfo.utcoffset(dtime) is not None) def relative_timedelta_str(day: dt.date) -> str: diff --git a/tests/conftest.py b/tests/conftest.py index 10bc52bb..f3f53db1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -48,7 +48,7 @@ def coll_vdirs(tmpdir) -> CollVdirType: for name in example_cals: path = str(tmpdir) + '/' + name os.makedirs(path, mode=0o770) - readonly = True if name == 'a_calendar' else False + readonly = name == 'a_calendar' calendars[name] = CalendarConfiguration( name=name, path=path, @@ -69,7 +69,7 @@ def coll_vdirs_birthday(tmpdir): for name in example_cals: path = str(tmpdir) + '/' + name os.makedirs(path, mode=0o770) - readonly = True if name == 'a_calendar' else False + readonly = name == 'a_calendar' calendars[name] = {'name': name, 'path': path, 'color': 'dark blue', 'readonly': readonly, 'unicode_symbols': True, 'ctype': 'birthdays'} vdirs[name] = Vdir(path, '.vcf') |