Merge pull request #7633 from hugovk/type-imagemode

Add type hints for ImageMode
This commit is contained in:
Andrew Murray 2023-12-23 22:10:10 +11:00 committed by GitHub
commit 41e45b5f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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: tuple[str, ...],
basemode: str,
basetype: 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: