66import math
77from fractions import Fraction
88from pathlib import Path
9+ from types import NotImplementedType
910
1011from django .core import checks
1112from django .core .files .base import ContentFile
@@ -105,7 +106,7 @@ def name(self) -> str:
105106 def path (self ) -> Path :
106107 return Path (self .storage .path (self .name ))
107108
108- def process (self , image ) -> Image :
109+ def process (self , image ) -> Image . Image :
109110 image = ImageOps .exif_transpose (image ) # crates a copy
110111 height = self .height or self .width / Fraction (* image .size )
111112 size = math .floor (self .width ), math .floor (height )
@@ -130,7 +131,7 @@ def delete(self):
130131
131132
132133class PictureFieldFile (ImageFieldFile ):
133- def __xor__ (self , other ) -> tuple [set [Picture ], set [Picture ]]:
134+ def __xor__ (self , other ) -> tuple [set [Picture ], set [Picture ]] | NotImplementedType :
134135 """Return the new and obsolete :class:`Picture` instances."""
135136 if not isinstance (other , PictureFieldFile ):
136137 return NotImplemented
@@ -192,7 +193,7 @@ def height(self):
192193 return self ._get_image_dimensions ()[1 ]
193194
194195 @property
195- def aspect_ratios (self ) -> { Fraction | None : { str : { int : Picture }}} :
196+ def aspect_ratios (self ) -> dict [ Fraction | None , dict [ str , dict [ int , Picture ]]] :
196197 self ._require_file ()
197198 return self .get_picture_files (
198199 file_name = self .name ,
@@ -210,7 +211,7 @@ def get_picture_files(
210211 img_height : int ,
211212 storage : Storage ,
212213 field : PictureField ,
213- ) -> { Fraction | None : { str : { int : Picture }}} :
214+ ) -> dict [ Fraction | None , dict [ str , dict [ int , Picture ]]] :
214215 PictureClass = import_string (conf .get_settings ().PICTURE_CLASS )
215216 return {
216217 ratio : {
@@ -291,7 +292,7 @@ def _check_aspect_ratios(self):
291292 return errors
292293
293294 def _check_width_height_field (self ):
294- if None in self . aspect_ratios and not (self .width_field and self .height_field ):
295+ if not (self .width_field and self .height_field ):
295296 return [
296297 checks .Warning (
297298 "width_field and height_field attributes are missing" ,
0 commit comments