Skip to content

Commit 84a02c8

Browse files
authored
Merge pull request #7944 from nulano/type-image-open
Add type hints for `Image.open`, `Image.init`, and `Image.Image.save`
2 parents 38f4c7b + 48b2705 commit 84a02c8

27 files changed

Lines changed: 59 additions & 42 deletions

src/PIL/BlpImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class BLPFormatError(NotImplementedError):
241241
pass
242242

243243

244-
def _accept(prefix):
244+
def _accept(prefix: bytes) -> bool:
245245
return prefix[:4] in (b"BLP1", b"BLP2")
246246

247247

src/PIL/BmpImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
}
4949

5050

51-
def _accept(prefix):
51+
def _accept(prefix: bytes) -> bool:
5252
return prefix[:2] == b"BM"
5353

5454

src/PIL/BufrStubImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def register_handler(handler):
2929
# Image adapter
3030

3131

32-
def _accept(prefix):
32+
def _accept(prefix: bytes) -> bool:
3333
return prefix[:4] == b"BUFR" or prefix[:4] == b"ZCZC"
3434

3535

src/PIL/CurImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# --------------------------------------------------------------------
2626

2727

28-
def _accept(prefix):
28+
def _accept(prefix: bytes) -> bool:
2929
return prefix[:4] == b"\0\0\2\0"
3030

3131

src/PIL/DcxImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
3030

3131

32-
def _accept(prefix):
32+
def _accept(prefix: bytes) -> bool:
3333
return len(prefix) >= 4 and i32(prefix) == MAGIC
3434

3535

src/PIL/DdsImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def _save(im, fp, filename):
562562
)
563563

564564

565-
def _accept(prefix):
565+
def _accept(prefix: bytes) -> bool:
566566
return prefix[:4] == b"DDS "
567567

568568

src/PIL/EpsImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def readline(self):
195195
return b"".join(s).decode("latin-1")
196196

197197

198-
def _accept(prefix):
198+
def _accept(prefix: bytes) -> bool:
199199
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
200200

201201

src/PIL/FliImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# decoder
2828

2929

30-
def _accept(prefix):
30+
def _accept(prefix: bytes) -> bool:
3131
return (
3232
len(prefix) >= 6
3333
and i16(prefix, 4) in [0xAF11, 0xAF12]

src/PIL/FpxImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# --------------------------------------------------------------------
4242

4343

44-
def _accept(prefix):
44+
def _accept(prefix: bytes) -> bool:
4545
return prefix[:8] == olefile.MAGIC
4646

4747

src/PIL/FtexImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def load_seek(self, pos):
107107
pass
108108

109109

110-
def _accept(prefix):
110+
def _accept(prefix: bytes) -> bool:
111111
return prefix[:4] == MAGIC
112112

113113

0 commit comments

Comments
 (0)