33from resolver_athena_client .generated .athena .models_pb2 import ImageFormat
44
55
6- def detect_image_format (data : bytes ) -> ImageFormat .ValueType :
6+ def detect_image_format (data : bytes ) -> ImageFormat .ValueType : # noqa: PLR0911
77 """Detect image format from raw bytes using magic number signatures.
88
99 Args:
@@ -20,27 +20,27 @@ def detect_image_format(data: bytes) -> ImageFormat.ValueType:
2020
2121 # Check magic numbers for common image formats
2222 # PNG: starts with \x89PNG (need at least 4 bytes)
23- if len (data ) >= 4 and data [:4 ] == b"\x89 PNG" :
23+ if len (data ) >= 4 and data [:4 ] == b"\x89 PNG" : # noqa: PLR2004
2424 return ImageFormat .IMAGE_FORMAT_PNG
2525
2626 # JPEG: starts with \xFF\xD8\xFF (need at least 3 bytes)
27- if len (data ) >= 3 and data [:3 ] == b"\xFF \xD8 \xFF " :
27+ if len (data ) >= 3 and data [:3 ] == b"\xFF \xD8 \xFF " : # noqa: PLR2004
2828 return ImageFormat .IMAGE_FORMAT_JPEG
2929
3030 # GIF: starts with GIF87a or GIF89a (need at least 6 bytes)
31- if len (data ) >= 6 and data [:6 ] in (b"GIF87a" , b"GIF89a" ):
31+ if len (data ) >= 6 and data [:6 ] in (b"GIF87a" , b"GIF89a" ): # noqa: PLR2004
3232 return ImageFormat .IMAGE_FORMAT_GIF
3333
3434 # BMP: starts with BM (need at least 2 bytes)
35- if len (data ) >= 2 and data [:2 ] == b"BM" :
35+ if len (data ) >= 2 and data [:2 ] == b"BM" : # noqa: PLR2004
3636 return ImageFormat .IMAGE_FORMAT_BMP
3737
3838 # WebP: starts with RIFF....WEBP (need at least 12 bytes)
39- if len (data ) >= 12 and data [:4 ] == b"RIFF" and data [8 :12 ] == b"WEBP" :
39+ if len (data ) >= 12 and data [:4 ] == b"RIFF" and data [8 :12 ] == b"WEBP" : # noqa: PLR2004
4040 return ImageFormat .IMAGE_FORMAT_WEBP
4141
4242 # TIFF: starts with II* or MM* (need at least 4 bytes)
43- if len (data ) >= 4 and data [:4 ] in (b"II*\x00 " , b"MM\x00 *" ):
43+ if len (data ) >= 4 and data [:4 ] in (b"II*\x00 " , b"MM\x00 *" ): # noqa: PLR2004
4444 return ImageFormat .IMAGE_FORMAT_TIFF
4545
4646 # If we can't detect the format, return UNSPECIFIED
0 commit comments