[pitivi] Fix pylint chained-comparison
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Fix pylint chained-comparison
- Date: Mon, 11 Nov 2019 22:08:06 +0000 (UTC)
commit e0091275e580886eb84a405503ec96c974c9a828
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Nov 1 23:02:45 2019 +0100
Fix pylint chained-comparison
pitivi/timeline/timeline.py | 4 ++--
pitivi/utils/loggable.py | 19 +++++--------------
pitivi/utils/widgets.py | 6 ++----
pre-commit.hook | 1 -
tests/test_log.py | 4 ----
5 files changed, 9 insertions(+), 25 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 33ce4673..86625b81 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -517,7 +517,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
layout_width = self.layout.get_allocation().width
if when_not_in_view:
x = self.nsToPixel(self.__last_position) - self.hadj.get_value()
- if x >= 0 and x <= layout_width:
+ if 0 <= x <= layout_width:
return
# Deciding the new position of the playhead in the timeline's view.
@@ -2007,7 +2007,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
for clip in clips:
start = clip.get_start()
end = start + clip.get_duration()
- if start < position and end > position:
+ if start < position < end:
layer = clip.get_layer()
layer.splitting_object = True
try:
diff --git a/pitivi/utils/loggable.py b/pitivi/utils/loggable.py
index 535ea081..fcf822d6 100644
--- a/pitivi/utils/loggable.py
+++ b/pitivi/utils/loggable.py
@@ -232,18 +232,9 @@ def get_level_name(level):
Returns:
str: The name of the level.
"""
- assert isinstance(level, int) and level > 0 and level < 7, \
+ assert isinstance(level, int) and 0 < level <= len(_LEVEL_NAMES), \
TypeError("Bad debug level")
- return get_level_names()[level - 1]
-
-
-def get_level_names():
- """Returns a list with the level names.
-
- Returns:
- List[str]: A list with the level names.
- """
- return _LEVEL_NAMES
+ return _LEVEL_NAMES[level - 1]
def get_level_int(level_name):
@@ -255,13 +246,13 @@ def get_level_int(level_name):
Returns:
int: The value of the level name we are interested in.
"""
- assert isinstance(level_name, str) and level_name in get_level_names(), \
+ assert isinstance(level_name, str) and level_name in _LEVEL_NAMES, \
"Bad debug level name"
- return get_level_names().index(level_name) + 1
+ return _LEVEL_NAMES.index(level_name) + 1
def get_formatted_level_name(level):
- assert isinstance(level, int) and level > 0 and level < len(_LEVEL_NAMES) + 1, \
+ assert isinstance(level, int) and 0 < level <= len(_LEVEL_NAMES), \
TypeError("Bad debug level")
return _FORMATTED_LEVELS[level - 1]
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 18ce05cc..ed2a02c8 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -385,8 +385,7 @@ class FractionWidget(TextWidget, DynamicWidget):
preset = self._parseText(preset)
else:
strval = "%g:%g" % (preset.num, preset.denom)
- fpreset = float(preset)
- if flow <= fpreset and fpreset <= fhigh:
+ if flow <= float(preset) <= fhigh:
choices.append(strval)
self.low = flow
self.high = fhigh
@@ -407,8 +406,7 @@ class FractionWidget(TextWidget, DynamicWidget):
preset = self._parseText(preset)
else:
strval = "%g:%g" % (preset.num, preset.denom)
- fpreset = float(preset)
- if self.low <= fpreset and fpreset <= self.high:
+ if self.low <= float(preset) <= self.high:
choices.append(strval)
self.addChoices(choices)
diff --git a/pre-commit.hook b/pre-commit.hook
index 5d6a0111..bc08995a 100755
--- a/pre-commit.hook
+++ b/pre-commit.hook
@@ -18,7 +18,6 @@ pitivi/medialibrary.py
pitivi/timeline/timeline.py
pitivi/utils/extract.py
pitivi/utils/loggable.py
-pitivi/utils/widgets.py
tests/test_project.py
"
diff --git a/tests/test_log.py b/tests/test_log.py
index 90bde593..3beda995 100644
--- a/tests/test_log.py
+++ b/tests/test_log.py
@@ -212,10 +212,6 @@ class TestLogSettings(unittest.TestCase):
class TestLogNames(unittest.TestCase):
- def testGetLevelNames(self):
- self.assertEqual(['ERROR', 'WARN', 'FIXME', 'INFO', 'DEBUG', 'LOG'],
- log.get_level_names())
-
def testGetLevelCode(self):
self.assertEqual(1, log.get_level_int('ERROR'))
self.assertEqual(2, log.get_level_int('WARN'))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]