Skip to content

Commit c18d0d0

Browse files
committed
fix mypy "truthy-bool" errors
1 parent cafc329 commit c18d0d0

6 files changed

Lines changed: 9 additions & 18 deletions

File tree

Tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def test_check_size(self) -> None:
570570
im = Image.new("L", (100, 0))
571571
assert im.size == (100, 0)
572572

573-
assert Image.new("RGB", (1, 1))
573+
assert isinstance(Image.new("RGB", (1, 1)), Image.Image)
574574
# Should pass lists too
575575
i = Image.new("RGB", [1, 1])
576576
assert isinstance(i.size, tuple)

Tests/test_pyarrow.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ def test_to_array(mode: str, dtype: pyarrow.DataType, mask: list[int] | None) ->
112112

113113
reloaded = Image.fromarrow(arr, mode, img.size)
114114

115-
assert reloaded
116-
117115
assert_image_equal(img, reloaded)
118116

119117

Tests/test_qt_image_qapplication.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ def roundtrip(expected: Image.Image) -> None:
5656
def test_sanity(tmp_path: Path) -> None:
5757
# Segfault test
5858
app: QApplication | None = QApplication([])
59-
ex = Example()
59+
ex = Example() # noqa: F841
6060
assert app # Silence warning
61-
assert ex # Silence warning
6261

6362
for mode in ("1", "RGB", "RGBA", "L", "P"):
6463
# to QPixmap

checks/check_png_dos.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def test_dos_text() -> None:
2828
try:
2929
im = Image.open(TEST_FILE)
3030
im.load()
31-
except ValueError as msg:
32-
assert msg, "Decompressed Data Too Large"
31+
except ValueError:
3332
return
3433

3534
assert isinstance(im, PngImagePlugin.PngImageFile)

src/PIL/Image.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,33 +438,28 @@ def preinit() -> None:
438438
return
439439

440440
try:
441-
from . import BmpImagePlugin
441+
from . import BmpImagePlugin as BmpImagePlugin
442442

443-
assert BmpImagePlugin
444443
except ImportError:
445444
pass
446445
try:
447-
from . import GifImagePlugin
446+
from . import GifImagePlugin as GifImagePlugin
448447

449-
assert GifImagePlugin
450448
except ImportError:
451449
pass
452450
try:
453-
from . import JpegImagePlugin
451+
from . import JpegImagePlugin as JpegImagePlugin
454452

455-
assert JpegImagePlugin
456453
except ImportError:
457454
pass
458455
try:
459-
from . import PpmImagePlugin
456+
from . import PpmImagePlugin as PpmImagePlugin
460457

461-
assert PpmImagePlugin
462458
except ImportError:
463459
pass
464460
try:
465-
from . import PngImagePlugin
461+
from . import PngImagePlugin as PngImagePlugin
466462

467-
assert PngImagePlugin
468463
except ImportError:
469464
pass
470465

src/PIL/ImageFont.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _load_pilfont(self, filename: str) -> None:
110110
except Exception:
111111
pass
112112
else:
113-
if image and image.mode in ("1", "L"):
113+
if image.mode in ("1", "L"):
114114
break
115115
else:
116116
if image:

0 commit comments

Comments
 (0)