Skip to content

Commit

Permalink
Refactor: fix warning for not using min (#849)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksei Stepanov <alekseis@nvidia.com>
  • Loading branch information
penguinolog and Aleksei Stepanov committed Feb 28, 2024
1 parent 210a79d commit ead68bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions urwid/widget/grid_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def _invalidate(self) -> None:
super()._invalidate()

def _contents_modified(
self, slc, new_items: Iterable[tuple[Widget, tuple[Literal["given", WHSettings.GIVEN], int]]]
self,
_slc: tuple[int, int, int],
new_items: Iterable[tuple[Widget, tuple[Literal["given", WHSettings.GIVEN], int]]],
) -> None:
for item in new_items:
try:
Expand Down Expand Up @@ -291,7 +293,7 @@ def focus(self) -> Widget | None:
return None
return self.contents[self.focus_position][0]

def _get_focus(self) -> Widget:
def _get_focus(self) -> Widget | None:
warnings.warn(
f"method `{self.__class__.__name__}._get_focus` is deprecated, "
f"please use `{self.__class__.__name__}.focus` property",
Expand Down Expand Up @@ -479,7 +481,7 @@ def generate_display_widget(self, size: tuple[int] | tuple[()]) -> Divider | Pil

# Use width == maxcol in case of maxcol < width amount
# Columns will use empty widget in case of GIVEN width > maxcol
c.contents.append((w, c.options(WHSettings.GIVEN, width_amount if width_amount <= maxcol else maxcol)))
c.contents.append((w, c.options(WHSettings.GIVEN, min(width_amount, maxcol))))
if (i == self.focus_position) or (not column_focused and w.selectable()):
c.focus_position = len(c.contents) - 1
column_focused = True
Expand Down

0 comments on commit ead68bb

Please sign in to comment.