From 768003148015376f1715a2d4cc0b3d6d800876c4 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Thu, 11 Jan 2024 16:28:28 +0100 Subject: [PATCH] Update deprecated syntax Squelches 165 warnings from tests. --- khal/ui/calendarwidget.py | 6 +++--- khal/ui/editor.py | 2 +- khal/ui/widgets.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/khal/ui/calendarwidget.py b/khal/ui/calendarwidget.py index 34b2d9844..38de6a28d 100644 --- a/khal/ui/calendarwidget.py +++ b/khal/ui/calendarwidget.py @@ -165,7 +165,7 @@ def focus_position(self) -> int: @focus_position.setter def focus_position(self, position: int) -> None: - """calls on_date_change before calling super()._set_focus_position""" + """calls on_date_change before setting super().focus_position""" # do not call when building up the interface, lots of potentially # expensive calls made here if self._init: @@ -180,7 +180,7 @@ def focus_position(self, position: int) -> None: def set_focus_date(self, a_date: dt.date) -> None: for num, day in enumerate(self.contents[1:8], 1): if day[0].date == a_date: - self._set_focus_position(num) + self.focus_position = num return None raise ValueError('%s not found in this week' % a_date) @@ -430,7 +430,7 @@ def set_focus_date(self, a_day: dt.date) -> None: self.reset(a_day) row, column = self.get_date_pos(a_day) self.set_focus(row) - self[self.focus]._set_focus_position(column) + self[self.focus].focus_position = (column) @property def earliest_date(self) -> dt.date: diff --git a/khal/ui/editor.py b/khal/ui/editor.py index c9b5975d5..82a9220ed 100644 --- a/khal/ui/editor.py +++ b/khal/ui/editor.py @@ -64,7 +64,7 @@ def __init__(self, widget, on_date_change, weeknumbers: Literal['left', 'right', self._monthdisplay = monthdisplay self._firstweekday = firstweekday self._keybindings = {} if keybindings is None else keybindings - self.__super.__init__(widget) + super().__init__(widget) def keypress(self, size, key): if key == 'enter': diff --git a/khal/ui/widgets.py b/khal/ui/widgets.py index 4a793ab61..568c6af28 100644 --- a/khal/ui/widgets.py +++ b/khal/ui/widgets.py @@ -258,7 +258,7 @@ def __init__(self, parent, callback=lambda: None) -> None: pile = NPile(buttons, outermost=True) num = [num for num, elem in enumerate(parent.choices) if elem == parent.active][0] - pile.set_focus(num) + pile.focus_position = num fill = urwid.Filler(pile) urwid.WidgetWrap.__init__(self, urwid.AttrMap(fill, 'popupbg')) @@ -287,14 +287,14 @@ class NextMixin(SupportsNext): def _select_first_selectable(self): """select our first selectable item (recursivly if that item SupportsNext)""" i = self._first_selectable() - self.set_focus(i) + self.focus_position = i if isinstance(self.contents[i][0], SupportsNext): self.contents[i][0]._select_first_selectable() def _select_last_selectable(self): """select our last selectable item (recursivly if that item SupportsNext)""" i = self._last_selectable() - self.set_focus(i) + self.focus_position = i if isinstance(self._contents[i][0], SupportsNext): self.contents[i][0]._select_last_selectable() @@ -321,7 +321,7 @@ def keypress(self, size, key): else: for i in range(self.focus_position + 1, len(self._contents)): if self._contents[i][0].selectable(): - self.set_focus(i) + self.focus_position = i if isinstance(self._contents[i][0], SupportsNext): self._contents[i][0]._select_first_selectable() break @@ -333,7 +333,7 @@ def keypress(self, size, key): else: for i in range(self.focus_position - 1, 0 - 1, -1): if self._contents[i][0].selectable(): - self.set_focus(i) + self.focus_position = i if isinstance(self._contents[i][0], SupportsNext): self._contents[i][0]._select_last_selectable() break @@ -355,14 +355,14 @@ class NListBox(SupportsNext, urwid.ListBox): def _select_first_selectable(self): """select our first selectable item (recursivly if that item SupportsNext)""" i = self._first_selectable() - self.set_focus(i) + self.focus_position = i if isinstance(self.body[i], SupportsNext): self.body[i]._select_first_selectable() def _select_last_selectable(self): """select our last selectable item (recursivly if that item SupportsNext)""" i = self._last_selectable() - self.set_focus(i) + self.focus_position = i if isinstance(self.body[i], SupportsNext): self.body[i]._select_last_selectable()