Skip to content

Commit

Permalink
Code refactoring: follow updated static checker rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Stepanov committed May 14, 2024
1 parent 3561671 commit df3178f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
5 changes: 1 addition & 4 deletions examples/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,7 @@ def starts_expanded(name: str) -> bool:
if len(path_elements) > len(_initial_cwd):
return False

if path_elements != _initial_cwd[: len(path_elements)]:
return False

return True
return path_elements == _initial_cwd[: len(path_elements)]


def escape_filename_sh(name: str) -> str:
Expand Down
4 changes: 1 addition & 3 deletions examples/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ def show_result(self, next_cell) -> bool:
return False
if next_cell is None:
return True
if self.op == next_cell.op == "+":
return False
return True
return not (self.op == next_cell.op == "+")

def setup_edit(self) -> None:
"""Create the standard edit widget for this cell."""
Expand Down
2 changes: 1 addition & 1 deletion urwid/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def shard_body_row(sbody):
else: # noqa: PLR5501 # pylint: disable=else-if-used # readability
# need to skip this unchanged canvas
if row and isinstance(row[-1], int):
row[-1] = row[-1] + cview[2]
row[-1] += cview[2]
else:
row.append(cview[2])

Expand Down
4 changes: 1 addition & 3 deletions urwid/display/_raw_display_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,7 @@ def set_cursor_position(x: int, y: int) -> str:
def is_blank_row(row: list[tuple[object, Literal["0", "U"] | None], bytes]) -> bool:
if len(row) > 1:
return False
if row[0][2].strip():
return False
return True
return not row[0][2].strip()

def attr_to_escape(a: AttrSpec | str | None) -> str:
if a in self._pal_escape:
Expand Down
4 changes: 2 additions & 2 deletions urwid/widget/bar_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def row_combine_last(count: int, row):
row_combine_last(count, row)
y_count -= count # noqa: PLW2901
r += count
r = r % 8
r %= 8
if not y_count:
continue
if r != 0:
Expand Down Expand Up @@ -508,7 +508,7 @@ def add_segment(seg_num: int, col: int, row: int, width: int, rows=rows) -> None

for r in rows:
if r is None:
y_count = y_count + 1
y_count += 1
continue
if y_count:
rowsets.append((y_count, last))
Expand Down

0 comments on commit df3178f

Please sign in to comment.