@@ -330,8 +330,10 @@ def test_exif_gps(self, tmp_path: Path) -> None:
330330
331331 # Reading
332332 with Image .open ("Tests/images/exif_gps.jpg" ) as im :
333- exif = im ._getexif ()
334- assert exif [gps_index ] == expected_exif_gps
333+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
334+ exif_data = im ._getexif ()
335+ assert exif_data is not None
336+ assert exif_data [gps_index ] == expected_exif_gps
335337
336338 # Writing
337339 f = tmp_path / "temp.jpg"
@@ -340,8 +342,10 @@ def test_exif_gps(self, tmp_path: Path) -> None:
340342 hopper ().save (f , exif = exif )
341343
342344 with Image .open (f ) as reloaded :
343- exif = reloaded ._getexif ()
344- assert exif [gps_index ] == expected_exif_gps
345+ assert isinstance (reloaded , JpegImagePlugin .JpegImageFile )
346+ exif_data = reloaded ._getexif ()
347+ assert exif_data is not None
348+ assert exif_data [gps_index ] == expected_exif_gps
345349
346350 def test_empty_exif_gps (self ) -> None :
347351 with Image .open ("Tests/images/empty_gps_ifd.jpg" ) as im :
@@ -368,6 +372,7 @@ def test_exif_equality(self) -> None:
368372 exifs = []
369373 for i in range (2 ):
370374 with Image .open ("Tests/images/exif-200dpcm.jpg" ) as im :
375+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
371376 exifs .append (im ._getexif ())
372377 assert exifs [0 ] == exifs [1 ]
373378
@@ -401,13 +406,17 @@ def test_exif_rollback(self) -> None:
401406 }
402407
403408 with Image .open ("Tests/images/exif_gps.jpg" ) as im :
409+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
404410 exif = im ._getexif ()
411+ assert exif is not None
405412
406413 for tag , value in expected_exif .items ():
407414 assert value == exif [tag ]
408415
409416 def test_exif_gps_typeerror (self ) -> None :
410417 with Image .open ("Tests/images/exif_gps_typeerror.jpg" ) as im :
418+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
419+
411420 # Should not raise a TypeError
412421 im ._getexif ()
413422
@@ -487,7 +496,9 @@ def getsampling(
487496
488497 def test_exif (self ) -> None :
489498 with Image .open ("Tests/images/pil_sample_rgb.jpg" ) as im :
499+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
490500 info = im ._getexif ()
501+ assert info is not None
491502 assert info [305 ] == "Adobe Photoshop CS Macintosh"
492503
493504 def test_get_child_images (self ) -> None :
@@ -690,11 +701,13 @@ def test_load_16bit_qtables(self) -> None:
690701
691702 def test_save_multiple_16bit_qtables (self ) -> None :
692703 with Image .open ("Tests/images/hopper_16bit_qtables.jpg" ) as im :
704+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
693705 im2 = self .roundtrip (im , qtables = "keep" )
694706 assert im .quantization == im2 .quantization
695707
696708 def test_save_single_16bit_qtable (self ) -> None :
697709 with Image .open ("Tests/images/hopper_16bit_qtables.jpg" ) as im :
710+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
698711 im2 = self .roundtrip (im , qtables = {0 : im .quantization [0 ]})
699712 assert len (im2 .quantization ) == 1
700713 assert im2 .quantization [0 ] == im .quantization [0 ]
@@ -898,7 +911,10 @@ def test_ifd_offset_exif(self) -> None:
898911 # in contrast to normal 8
899912 with Image .open ("Tests/images/exif-ifd-offset.jpg" ) as im :
900913 # Act / Assert
901- assert im ._getexif ()[306 ] == "2017:03:13 23:03:09"
914+ assert isinstance (im , JpegImagePlugin .JpegImageFile )
915+ exif = im ._getexif ()
916+ assert exif is not None
917+ assert exif [306 ] == "2017:03:13 23:03:09"
902918
903919 def test_multiple_exif (self ) -> None :
904920 with Image .open ("Tests/images/multiple_exif.jpg" ) as im :
0 commit comments