Skip to content

Commit 08b9c86

Browse files
authored
Use assignments for enums in pillow (#11959)
1 parent d9f47c3 commit 08b9c86

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

stubs/Pillow/PIL/DdsImagePlugin.pyi

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -218,23 +218,23 @@ class D3DFMT(IntEnum):
218218
A2B10G10R10_XR_BIAS = 119
219219
BINARYBUFFER = 199
220220

221-
UYVY: int
222-
R8G8_B8G8: int
223-
YUY2: int
224-
G8R8_G8B8: int
225-
DXT1: int
226-
DXT2: int
227-
DXT3: int
228-
DXT4: int
229-
DXT5: int
230-
DX10: int
231-
BC4S: int
232-
BC4U: int
233-
BC5S: int
234-
BC5U: int
235-
ATI1: int
236-
ATI2: int
237-
MULTI2_ARGB8: int
221+
UYVY = 1498831189 # i32(b"UYVY")
222+
R8G8_B8G8 = 1195525970 # i32(b"RGBG")
223+
YUY2 = 844715353 # i32(b"YUY2")
224+
G8R8_G8B8 = 1111970375 # i32(b"GRGB")
225+
DXT1 = 827611204 # i32(b"DXT1")
226+
DXT2 = 844388420 # i32(b"DXT2")
227+
DXT3 = 861165636 # i32(b"DXT3")
228+
DXT4 = 877942852 # i32(b"DXT4")
229+
DXT5 = 894720068 # i32(b"DXT5")
230+
DX10 = 808540228 # i32(b"DX10")
231+
BC4S = 1395934018 # i32(b"BC4S")
232+
BC4U = 1429488450 # i32(b"BC4U")
233+
BC5S = 1395999554 # i32(b"BC5S")
234+
BC5U = 1429553986 # i32(b"BC5U")
235+
ATI1 = 826889281 # i32(b"ATI1")
236+
ATI2 = 843666497 # i32(b"ATI2")
237+
MULTI2_ARGB8 = 827606349 # i32(b"MET1")
238238

239239
DDSD_CAPS: Final = 0x1
240240
DDSD_HEIGHT: Final = 0x2

stubs/Pillow/PIL/Image.pyi

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from _typeshed import Incomplete, SupportsRead, SupportsWrite, Unused
22
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
33
from enum import IntEnum
44
from pathlib import Path
5-
from typing import Any, ClassVar, Literal, Protocol, SupportsBytes
5+
from typing import Any, ClassVar, Final, Literal, Protocol, SupportsBytes
66
from typing_extensions import Self, TypeAlias, TypeGuard
77

88
from PIL.PyAccess import PyAccess
@@ -65,13 +65,13 @@ class Transpose(IntEnum):
6565
TRANSVERSE = 6
6666

6767
# All Transpose items
68-
FLIP_LEFT_RIGHT: Literal[0]
69-
FLIP_TOP_BOTTOM: Literal[1]
70-
ROTATE_90: Literal[2]
71-
ROTATE_180: Literal[3]
72-
ROTATE_270: Literal[4]
73-
TRANSPOSE: Literal[5]
74-
TRANSVERSE: Literal[6]
68+
FLIP_LEFT_RIGHT: Final = 0
69+
FLIP_TOP_BOTTOM: Final = 1
70+
ROTATE_90: Final = 2
71+
ROTATE_180: Final = 3
72+
ROTATE_270: Final = 4
73+
TRANSPOSE: Final = 5
74+
TRANSVERSE: Final = 6
7575

7676
class Transform(IntEnum):
7777
AFFINE = 0
@@ -81,11 +81,11 @@ class Transform(IntEnum):
8181
MESH = 4
8282

8383
# All Transform items
84-
AFFINE: Literal[0]
85-
EXTENT: Literal[1]
86-
PERSPECTIVE: Literal[2]
87-
QUAD: Literal[3]
88-
MESH: Literal[4]
84+
AFFINE: Final = 0
85+
EXTENT: Final = 1
86+
PERSPECTIVE: Final = 2
87+
QUAD: Final = 3
88+
MESH: Final = 4
8989

9090
class Resampling(IntEnum):
9191
NEAREST = 0
@@ -96,12 +96,12 @@ class Resampling(IntEnum):
9696
HAMMING = 5
9797

9898
# All Resampling items
99-
NEAREST: Literal[0]
100-
LANCZOS: Literal[1]
101-
BILINEAR: Literal[2]
102-
BICUBIC: Literal[3]
103-
BOX: Literal[4]
104-
HAMMING: Literal[5]
99+
NEAREST: Final = 0
100+
LANCZOS: Final = 1
101+
BILINEAR: Final = 2
102+
BICUBIC: Final = 3
103+
BOX: Final = 4
104+
HAMMING: Final = 5
105105

106106
class Dither(IntEnum):
107107
NONE = 0
@@ -110,18 +110,18 @@ class Dither(IntEnum):
110110
FLOYDSTEINBERG = 3
111111

112112
# All Dither items
113-
NONE: Literal[0]
114-
ORDERED: Literal[1]
115-
RASTERIZE: Literal[2]
116-
FLOYDSTEINBERG: Literal[3]
113+
NONE: Final = 0
114+
ORDERED: Final = 1
115+
RASTERIZE: Final = 2
116+
FLOYDSTEINBERG: Final = 3
117117

118118
class Palette(IntEnum):
119119
WEB = 0
120120
ADAPTIVE = 1
121121

122122
# All Palette items
123-
WEB: Literal[0]
124-
ADAPTIVE: Literal[1]
123+
WEB: Final = 0
124+
ADAPTIVE: Final = 1
125125

126126
class Quantize(IntEnum):
127127
MEDIANCUT = 0
@@ -130,10 +130,10 @@ class Quantize(IntEnum):
130130
LIBIMAGEQUANT = 3
131131

132132
# All Quantize items
133-
MEDIANCUT: Literal[0]
134-
MAXCOVERAGE: Literal[1]
135-
FASTOCTREE: Literal[2]
136-
LIBIMAGEQUANT: Literal[3]
133+
MEDIANCUT: Final = 0
134+
MAXCOVERAGE: Final = 1
135+
FASTOCTREE: Final = 2
136+
LIBIMAGEQUANT: Final = 3
137137

138138
ID: list[str]
139139
OPEN: dict[str, Any]

stubs/Pillow/PIL/_binary.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
def i8(c): ...
2-
def o8(i): ...
3-
def i16le(c, o: int = 0): ...
4-
def si16le(c, o: int = 0): ...
5-
def si16be(c, o: int = 0): ...
6-
def i32le(c, o: int = 0): ...
7-
def si32le(c, o: int = 0): ...
8-
def i16be(c, o: int = 0): ...
9-
def i32be(c, o: int = 0): ...
10-
def o16le(i): ...
11-
def o32le(i): ...
12-
def o16be(i): ...
13-
def o32be(i): ...
1+
def i8(c: bytes) -> int: ...
2+
def o8(i: int) -> bytes: ...
3+
def i16le(c: bytes, o: int = 0) -> int: ...
4+
def si16le(c: bytes, o: int = 0) -> int: ...
5+
def si16be(c: bytes, o: int = 0) -> int: ...
6+
def i32le(c: bytes, o: int = 0) -> int: ...
7+
def si32le(c: bytes, o: int = 0) -> int: ...
8+
def i16be(c: bytes, o: int = 0) -> int: ...
9+
def i32be(c: bytes, o: int = 0) -> int: ...
10+
def o16le(i: int) -> bytes: ...
11+
def o32le(i: int) -> bytes: ...
12+
def o16be(i: int) -> bytes: ...
13+
def o32be(i: int) -> bytes: ...

0 commit comments

Comments
 (0)