From 05d231460600f485dd954cca88f73967b4fdd790 Mon Sep 17 00:00:00 2001 From: Yay295 Date: Sat, 6 Apr 2024 15:52:17 -0500 Subject: [PATCH] Make ModeDescriptor a NamedTuple --- src/PIL/ImageMode.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/PIL/ImageMode.py b/src/PIL/ImageMode.py index 0b31f6081..b0c846553 100644 --- a/src/PIL/ImageMode.py +++ b/src/PIL/ImageMode.py @@ -16,24 +16,17 @@ from __future__ import annotations import sys from functools import lru_cache +from typing import NamedTuple -class ModeDescriptor: +class ModeDescriptor(NamedTuple): """Wrapper for mode strings.""" - 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 + mode: str + bands: tuple[str, ...] + basemode: str + basetype: str + typestr: str def __str__(self) -> str: return self.mode