From c5a0d72c1040fb028490c5c5fcab62a33d87b8fd Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 16 Dec 2017 09:33:04 -0800 Subject: [PATCH] Remove unnecessary bool() calls throughout project Can use truthy values in boolean expressions without first coercing to a bool. Removes unnecessary call to bool(). --- PIL/Image.py | 2 +- Tests/helper.py | 2 +- Tests/test_image.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index 0ff3c8a80..84fdaba8e 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -2753,7 +2753,7 @@ def registered_extensions(): Returns a dictionary containing all file extensions belonging to registered plugins """ - if not bool(EXTENSION): + if not EXTENSION: init() return EXTENSION diff --git a/Tests/helper.py b/Tests/helper.py index 442886d5a..117c5da54 100644 --- a/Tests/helper.py +++ b/Tests/helper.py @@ -165,7 +165,7 @@ class PillowTestCase(unittest.TestCase): travis=None, interpreter=None): # Skip if platform/travis matches, and # PILLOW_RUN_KNOWN_BAD is not true in the environment. - if bool(os.environ.get('PILLOW_RUN_KNOWN_BAD', False)): + if os.environ.get('PILLOW_RUN_KNOWN_BAD', False): print(os.environ.get('PILLOW_RUN_KNOWN_BAD', False)) return diff --git a/Tests/test_image.py b/Tests/test_image.py index 1d729e9de..e2859d237 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -312,7 +312,7 @@ class TestImage(PillowTestCase): extensions = Image.registered_extensions() # Assert - self.assertTrue(bool(extensions)) + self.assertTrue(extensions) for ext in ['.cur', '.icns', '.tif', '.tiff']: self.assertIn(ext, extensions)