about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2020-01-15 22:22:25 +0100
committertoonn <toonn@toonn.io>2020-07-05 15:23:44 +0200
commit9c67e02c14d0c8dda0cba2da066ce96fa989fe54 (patch)
tree0a7e1d863df6088dc474054b9054974de17ba375
parent92a54df8a588af27924bfeb0fbdc75f7f6abc22f (diff)
downloadranger-9c67e02c14d0c8dda0cba2da066ce96fa989fe54.tar.gz
Use chained comparison instead of multiple clauses
-rw-r--r--ranger/gui/ansi.py10
-rw-r--r--ranger/gui/displayable.py4
-rw-r--r--ranger/gui/ui.py2
-rw-r--r--ranger/gui/widgets/browsercolumn.py2
4 files changed, 9 insertions, 9 deletions
diff --git a/ranger/gui/ansi.py b/ranger/gui/ansi.py
index 1a0c8c52..3d33688d 100644
--- a/ranger/gui/ansi.py
+++ b/ranger/gui/ansi.py
@@ -80,21 +80,21 @@ def text_with_fg_bg_attr(ansi_text):  # pylint: disable=too-many-branches,too-ma
                 elif n == 28:
                     attr &= not color.invisible
 
-                elif n >= 30 and n <= 37:         # 8 ansi foreground and background colors
+                elif 30 <= n <= 37:  # 8 ansi foreground and background colors
                     fg = n - 30
                 elif n == 39:
                     fg = -1
-                elif n >= 40 and n <= 47:
+                elif 40 <= n <= 47:
                     bg = n - 40
                 elif n == 49:
                     bg = -1
 
                 # 8 aixterm high intensity colors (light but not bold)
-                elif n >= 90 and n <= 97:
+                elif 90 <= n <= 97:
                     fg = n - 90 + 8
                 elif n == 99:
                     fg = -1
-                elif n >= 100 and n <= 107:
+                elif 100 <= n <= 107:
                     bg = n - 100 + 8
                 elif n == 109:
                     bg = -1
@@ -159,7 +159,7 @@ def char_slice(ansi_text, start, length):
         pos += len(chunk)
         if pos <= start:
             pass  # seek
-        elif old_pos < start and pos >= start:
+        elif old_pos < start <= pos:
             chunks.append(last_color)
             chunks.append(str(chunk[start - old_pos:start - old_pos + length]))
         elif pos > length + start:
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py
index fd4eb3b9..0a8e09c6 100644
--- a/ranger/gui/displayable.py
+++ b/ranger/gui/displayable.py
@@ -110,8 +110,8 @@ class Displayable(  # pylint: disable=too-many-instance-attributes
 
         x and y should be absolute coordinates.
         """
-        return (x >= self.x and x < self.x + self.wid) and \
-            (y >= self.y and y < self.y + self.hei)
+        return (self.x <= x < self.x + self.wid) and \
+            (self.y <= y < self.y + self.hei)
 
     def click(self, event):
         """Called when a mouse key is pressed and self.focused is True.
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index a2ea7778..d820d4a9 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -239,7 +239,7 @@ class UI(  # pylint: disable=too-many-instance-attributes,too-many-public-method
         key = self.win.getch()
         if key == curses.KEY_ENTER:
             key = ord('\n')
-        if key == 27 or (key >= 128 and key < 256):
+        if key == 27 or (128 <= key < 256):
             # Handle special keys like ALT+X or unicode here:
             keys = [key]
             previous_load_mode = self.load_mode
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 8632cc46..330823b3 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -539,7 +539,7 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
             self.target.scroll_begin = dirsize - winsize
             return self._get_scroll_begin()
 
-        if projected < upper_limit and projected > lower_limit:
+        if lower_limit < projected < upper_limit:
             return original
 
         if projected > upper_limit: