@@ -118,7 +118,7 @@ class _TarFile:
118118 def __init__ (self , filepath : Path , mode : Literal ["r" ]) -> None :
119119 self .tar : tarfile .TarFile
120120 self .filepath = filepath
121- self .mode = mode
121+ self .mode : Literal [ "r" ] = mode
122122
123123 def namelist (self ) -> list [str ]:
124124 return self .tar .getnames ()
@@ -127,10 +127,10 @@ def read(self, name: str) -> bytes:
127127 return unwrap (self .tar .extractfile (name )).read ()
128128
129129 def __enter__ (self ) -> "_TarFile" :
130- self .tar = tarfile .open (self .filepath , self .mode ).__enter__ ()
130+ self .tar = tarfile .open (name = self .filepath , mode = self .mode ).__enter__ ()
131131 return self
132132
133- def __exit__ (self , * args ) -> None :
133+ def __exit__ (self , * args ) -> None : # pyright: ignore[reportUnknownParameterType, reportMissingParameterType]
134134 self .tar .__exit__ (* args )
135135
136136
@@ -293,7 +293,7 @@ def _render_mask(
293293
294294 im : Image .Image = Image .new (
295295 mode = "L" ,
296- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
296+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
297297 color = "black" ,
298298 )
299299 draw = ImageDraw .Draw (im )
@@ -324,7 +324,7 @@ def _render_edge(
324324 # Highlight
325325 im_hl : Image .Image = Image .new (
326326 mode = "RGBA" ,
327- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
327+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
328328 color = "#00000000" ,
329329 )
330330 draw = ImageDraw .Draw (im_hl )
@@ -343,7 +343,7 @@ def _render_edge(
343343 # Shadow
344344 im_sh : Image .Image = Image .new (
345345 mode = "RGBA" ,
346- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
346+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
347347 color = "#00000000" ,
348348 )
349349 draw = ImageDraw .Draw (im_sh )
@@ -388,21 +388,21 @@ def _render_center_icon(
388388 # Create larger blank image based on smooth_factor
389389 im : Image .Image = Image .new (
390390 "RGBA" ,
391- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
391+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
392392 color = "#FF000000" ,
393393 )
394394
395395 # Create solid background color
396396 bg : Image .Image
397397 bg = Image .new (
398398 "RGB" ,
399- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
399+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
400400 color = "#000000FF" ,
401401 )
402402
403403 # Use a background image if provided
404404 if bg_image :
405- bg_im = Image .Image .resize (bg_image , size = tuple ([d * smooth_factor for d in size ])) # type: ignore
405+ bg_im = Image .Image .resize (bg_image , size = tuple ([d * smooth_factor for d in size ])) # type: ignore # pyright: ignore[reportArgumentType]
406406 bg_im = ImageEnhance .Brightness (bg_im ).enhance (0.3 ) # Reduce the brightness
407407 bg .paste (bg_im )
408408
@@ -411,7 +411,7 @@ def _render_center_icon(
411411 bg ,
412412 (0 , 0 ),
413413 mask = self ._get_mask (
414- tuple ([d * smooth_factor for d in size ]), # type: ignore
414+ tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
415415 (pixel_ratio * smooth_factor ),
416416 ),
417417 )
@@ -495,19 +495,19 @@ def _render_corner_icon(
495495 # Create larger blank image based on smooth_factor
496496 im : Image .Image = Image .new (
497497 "RGBA" ,
498- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
498+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
499499 color = "#00000000" ,
500500 )
501501
502502 bg : Image .Image
503503 # Use a background image if provided
504504 if bg_image :
505- bg = Image .Image .resize (bg_image , size = tuple ([d * smooth_factor for d in size ])) # type: ignore
505+ bg = Image .Image .resize (bg_image , size = tuple ([d * smooth_factor for d in size ])) # type: ignore # pyright: ignore[reportArgumentType]
506506 # Create solid background color
507507 else :
508508 bg = Image .new (
509509 "RGB" ,
510- size = tuple ([d * smooth_factor for d in size ]), # type: ignore
510+ size = tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
511511 color = "#000000" ,
512512 )
513513 # Apply color overlay
@@ -521,7 +521,7 @@ def _render_corner_icon(
521521 bg ,
522522 (0 , 0 ),
523523 mask = self ._get_mask (
524- tuple ([d * smooth_factor for d in size ]), # type: ignore
524+ tuple ([d * smooth_factor for d in size ]), # type: ignore # pyright: ignore[reportArgumentType]
525525 (pixel_ratio * smooth_factor ),
526526 ),
527527 )
@@ -662,17 +662,17 @@ def _audio_album_thumb(filepath: Path, ext: str) -> Image.Image | None:
662662 artwork = None
663663 if ext in [".mp3" ]:
664664 id3_tags : id3 .ID3 = id3 .ID3 (filepath )
665- id3_covers : list = id3_tags .getall ("APIC" )
665+ id3_covers : list = id3_tags .getall ("APIC" ) # pyright: ignore[reportUnknownVariableType]
666666 if id3_covers :
667667 artwork = Image .open (BytesIO (id3_covers [0 ].data ))
668668 elif ext in [".flac" ]:
669669 flac_tags : flac .FLAC = flac .FLAC (filepath )
670- flac_covers : list = flac_tags .pictures
670+ flac_covers : list = flac_tags .pictures # pyright: ignore[reportUnknownVariableType]
671671 if flac_covers :
672672 artwork = Image .open (BytesIO (flac_covers [0 ].data ))
673673 elif ext in [".mp4" , ".m4a" , ".aac" ]:
674674 mp4_tags : mp4 .MP4 = mp4 .MP4 (filepath )
675- mp4_covers : list | None = mp4_tags .get ("covr" ) # pyright: ignore[reportAssignmentType ]
675+ mp4_covers : list | None = mp4_tags .get ("covr" ) # pyright: ignore[reportUnknownVariableType ]
676676 if mp4_covers :
677677 artwork = Image .open (BytesIO (mp4_covers [0 ]))
678678 if artwork :
@@ -1088,7 +1088,7 @@ def _font_long_thumb(filepath: Path, size: int) -> Image.Image | None:
10881088 font = ImageFont .truetype (filepath , size = font_size )
10891089 text_wrapped : str = wrap_full_text (
10901090 FONT_SAMPLE_TEXT ,
1091- font = font , # pyright: ignore[reportArgumentType]
1091+ font = font ,
10921092 width = size ,
10931093 draw = draw ,
10941094 )
@@ -1120,8 +1120,8 @@ def _image_raw_thumb(filepath: Path) -> Image.Image | None:
11201120 )
11211121 except (
11221122 DecompressionBombError ,
1123- rawpy .LibRawIOError ,
1124- rawpy .LibRawFileUnsupportedError ,
1123+ rawpy .LibRawIOError , # pyright: ignore[reportPrivateImportUsage]
1124+ rawpy .LibRawFileUnsupportedError , # pyright: ignore[reportPrivateImportUsage]
11251125 ) as e :
11261126 logger .error ("Couldn't render thumbnail" , filepath = filepath , error = type (e ).__name__ )
11271127 return im
@@ -1137,6 +1137,7 @@ def _image_exr_thumb(filepath: Path) -> Image.Image | None:
11371137 try :
11381138 # Load the EXR data to an array and rotate the color space from BGRA -> RGBA
11391139 raw_array = cv2 .imread (str (filepath ), cv2 .IMREAD_UNCHANGED )
1140+ assert raw_array
11401141 raw_array [..., :3 ] = raw_array [..., 2 ::- 1 ]
11411142
11421143 # Correct the gamma of the raw array
@@ -1209,7 +1210,7 @@ def _image_vector_thumb(filepath: Path, size: int) -> Image.Image:
12091210 # Write the image to a buffer as png
12101211 buffer : QBuffer = QBuffer ()
12111212 buffer .open (QBuffer .OpenModeFlag .ReadWrite )
1212- q_image .save (buffer , "PNG" ) # type: ignore[call-overload ]
1213+ q_image .save (device = buffer , format = "PNG" ) # type: ignore # pyright: ignore[reportArgumentType ]
12131214
12141215 # Load the image from the buffer
12151216 im = Image .new ("RGB" , (size , size ), color = "#1e1e1e" )
@@ -1258,7 +1259,7 @@ def get_image(path: str) -> Image.Image | None:
12581259 return im
12591260
12601261 @staticmethod
1261- def _model_stl_thumb (filepath : Path , size : int ) -> Image .Image | None :
1262+ def _model_stl_thumb (filepath : Path , size : int ) -> Image .Image | None : # pyright: ignore[reportUnusedParameter]
12621263 """Render a thumbnail for an STL file.
12631264
12641265 Args:
@@ -1614,6 +1615,7 @@ def render_ignored(
16141615
16151616 def fetch_cached_image (file_name : Path ):
16161617 image : Image .Image | None = None
1618+ assert self .driver .cache_manager
16171619 cached_path = self .driver .cache_manager .get_file_path (file_name )
16181620
16191621 if cached_path and cached_path .is_file ():
@@ -1876,6 +1878,7 @@ def _render(
18761878 image = self ._resize_image (image , (adj_size , adj_size ))
18771879
18781880 if save_to_file and savable_media_type and image :
1881+ assert self .driver .cache_manager
18791882 self .driver .cache_manager .save_image (image , save_to_file , mode = "RGBA" )
18801883
18811884 except (
0 commit comments