Skip to content

Commit

Permalink
Update deprecated syntax
Browse files Browse the repository at this point in the history
Squelches 165 warnings from tests.
  • Loading branch information
WhyNotHugo authored and geier committed Jan 21, 2024
1 parent 300aff0 commit 7680031
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions khal/ui/calendarwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion khal/ui/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
14 changes: 7 additions & 7 deletions khal/ui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()

Expand Down

0 comments on commit 7680031

Please sign in to comment.