diff options
author | Hugo Osvaldo Barrera <hugo@whynothugo.nl> | 2023-06-06 12:01:58 +0200 |
---|---|---|
committer | Hugo Osvaldo Barrera <hugo@whynothugo.nl> | 2023-06-06 12:22:51 +0200 |
commit | 0cec8c0e802c63331481dff6f58ddd07fb5ebb7e (patch) | |
tree | 6b8aa99160395d7bd4ec73111b7944cd8f38faca | |
parent | f22d4c124f3809fa47851ffecec583d9fbeaec8d (diff) |
Collapse nested `if` conditions
-rw-r--r-- | khal/controllers.py | 5 | ||||
-rw-r--r-- | khal/terminal.py | 5 | ||||
-rw-r--r-- | khal/ui/__init__.py | 7 | ||||
-rw-r--r-- | khal/ui/widgets.py | 10 |
4 files changed, 12 insertions, 15 deletions
diff --git a/khal/controllers.py b/khal/controllers.py index 64f43e6e..09eaa2b7 100644 --- a/khal/controllers.py +++ b/khal/controllers.py @@ -564,9 +564,8 @@ def edit_event(event, collection, locale, allow_quit=False, width=80): def edit(collection, search_string, locale, format=None, allow_past=False, conf=None): - if conf is not None: - if format is None: - format = conf['view']['event_format'] + if conf is not None and format is None: + format = conf['view']['event_format'] term_width, _ = get_terminal_size() now = conf['locale']['local_timezone'].localize(dt.datetime.now()) diff --git a/khal/terminal.py b/khal/terminal.py index 2274a17c..ffb1e386 100644 --- a/khal/terminal.py +++ b/khal/terminal.py @@ -87,9 +87,8 @@ def get_color( else: # background color c = 40 + COLORS[colorstring].color_index - if COLORS[colorstring].light: - if not bold_for_light_color: - c += 60 + if COLORS[colorstring].light and not bold_for_light_color: + c += 60 color += str(c) elif colorstring.isdigit(): # 256 color palette diff --git a/khal/ui/__init__.py b/khal/ui/__init__.py index 53ce9895..0f7bbe44 100644 --- a/khal/ui/__init__.py +++ b/khal/ui/__init__.py @@ -165,10 +165,9 @@ class U_Event(urwid.Text): :param event: the encapsulated event :type event: khal.event.Event """ - if relative: - if isinstance(this_date, dt.datetime) or not isinstance(this_date, dt.date): - raise ValueError(f'`this_date` is of type `{type(this_date)}`, ' - 'should be `datetime.date`') + if relative and (isinstance(this_date, dt.datetime) or not isinstance(this_date, dt.date)): + raise ValueError(f'`this_date` is of type `{type(this_date)}`, ' + 'should be `datetime.date`') self.event = event self.delete_status = delete_status self.this_date = this_date diff --git a/khal/ui/widgets.py b/khal/ui/widgets.py index 28eb54be..826c216f 100644 --- a/khal/ui/widgets.py +++ b/khal/ui/widgets.py @@ -433,11 +433,11 @@ class ValidatedEdit(urwid.WidgetWrap): def keypress(self, size, key): if ( - key in ['up', 'down', 'tab', 'shift tab'] or - (key in ['right'] and self.edit_pos >= len(self.edit_text)) or - (key in ['left'] and self.edit_pos == 0)): - if not self._validate(): - return + key in ['up', 'down', 'tab', 'shift tab'] or + (key in ['right'] and self.edit_pos >= len(self.edit_text)) or + (key in ['left'] and self.edit_pos == 0) + ) and not self._validate(): + return return super().keypress(size, key) |