Add type hints for ImageMode

This commit is contained in:
Hugo van Kemenade 2023-12-22 16:23:28 +02:00
parent e9453a7b88
commit 76809f09ef

View File

@ -23,18 +23,25 @@ _modes = None
class ModeDescriptor:
"""Wrapper for mode strings."""
def __init__(self, mode, bands, basemode, basetype, typestr):
def __init__(
self,
mode: str,
bands: str | tuple[str, ...],
basemode: str,
basetype: str | tuple[str, ...],
typestr: str,
) -> None:
self.mode = mode
self.bands = bands
self.basemode = basemode
self.basetype = basetype
self.typestr = typestr
def __str__(self):
def __str__(self) -> str:
return self.mode
def getmode(mode):
def getmode(mode: str) -> ModeDescriptor:
"""Gets a mode descriptor for the given mode."""
global _modes
if not _modes: