This commit is contained in:
Joren Hammudoglu 2026-02-03 07:24:23 +00:00 committed by GitHub
commit d12475751c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 10 additions and 19 deletions

View File

@ -572,7 +572,7 @@ class TestImage:
im = Image.new("L", (100, 0))
assert im.size == (100, 0)
assert Image.new("RGB", (1, 1))
assert isinstance(Image.new("RGB", (1, 1)), Image.Image)
# Should pass lists too
i = Image.new("RGB", [1, 1])
assert isinstance(i.size, tuple)

View File

@ -112,8 +112,6 @@ def test_to_array(mode: str, dtype: pyarrow.DataType, mask: list[int] | None) ->
reloaded = Image.fromarrow(arr, mode, img.size)
assert reloaded
assert_image_equal(img, reloaded)

View File

@ -56,9 +56,8 @@ def roundtrip(expected: Image.Image) -> None:
def test_sanity(tmp_path: Path) -> None:
# Segfault test
app: QApplication | None = QApplication([])
ex = Example()
ex = Example() # noqa: F841
assert app # Silence warning
assert ex # Silence warning
for mode in ("1", "RGB", "RGBA", "L", "P"):
# to QPixmap

View File

@ -28,8 +28,7 @@ def test_dos_text() -> None:
try:
im = Image.open(TEST_FILE)
im.load()
except ValueError as msg:
assert msg, "Decompressed Data Too Large"
except ValueError:
return
assert isinstance(im, PngImagePlugin.PngImageFile)

View File

@ -218,7 +218,7 @@ python_version = "3.10"
pretty = true
disallow_any_generics = true
disallow_untyped_defs = true
enable_error_code = "ignore-without-code"
enable_error_code = [ "ignore-without-code", "truthy-bool" ]
extra_checks = true
follow_imports = "silent"
warn_redundant_casts = true

View File

@ -438,33 +438,28 @@ def preinit() -> None:
return
try:
from . import BmpImagePlugin
from . import BmpImagePlugin as BmpImagePlugin
assert BmpImagePlugin
except ImportError:
pass
try:
from . import GifImagePlugin
from . import GifImagePlugin as GifImagePlugin
assert GifImagePlugin
except ImportError:
pass
try:
from . import JpegImagePlugin
from . import JpegImagePlugin as JpegImagePlugin
assert JpegImagePlugin
except ImportError:
pass
try:
from . import PpmImagePlugin
from . import PpmImagePlugin as PpmImagePlugin
assert PpmImagePlugin
except ImportError:
pass
try:
from . import PngImagePlugin
from . import PngImagePlugin as PngImagePlugin
assert PngImagePlugin
except ImportError:
pass

View File

@ -110,7 +110,7 @@ class ImageFont:
except Exception:
pass
else:
if image and image.mode in ("1", "L"):
if image.mode in ("1", "L"):
break
else:
if image: