mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Added further type hints
This commit is contained in:
parent
aa605bc6f2
commit
e1ea522f70
|
@ -3190,7 +3190,7 @@ def _decompression_bomb_check(size):
|
|||
)
|
||||
|
||||
|
||||
def open(fp, mode="r", formats=None):
|
||||
def open(fp, mode="r", formats=None) -> Image:
|
||||
"""
|
||||
Opens and identifies the given image file.
|
||||
|
||||
|
@ -3415,7 +3415,7 @@ def merge(mode, bands):
|
|||
# Plugin registry
|
||||
|
||||
|
||||
def register_open(id, factory, accept=None):
|
||||
def register_open(id, factory, accept=None) -> None:
|
||||
"""
|
||||
Register an image file plugin. This function should not be used
|
||||
in application code.
|
||||
|
@ -3469,7 +3469,7 @@ def register_save_all(id, driver):
|
|||
SAVE_ALL[id.upper()] = driver
|
||||
|
||||
|
||||
def register_extension(id, extension):
|
||||
def register_extension(id, extension) -> None:
|
||||
"""
|
||||
Registers an image extension. This function should not be
|
||||
used in application code.
|
||||
|
|
|
@ -18,6 +18,7 @@ from __future__ import annotations
|
|||
|
||||
import os
|
||||
import tempfile
|
||||
from typing import Sequence
|
||||
|
||||
from . import Image, ImageFile
|
||||
from ._binary import i16be as i16
|
||||
|
@ -27,7 +28,7 @@ from ._deprecate import deprecate
|
|||
COMPRESSION = {1: "raw", 5: "jpeg"}
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
def __getattr__(name: str) -> bytes:
|
||||
if name == "PAD":
|
||||
deprecate("IptcImagePlugin.PAD", 12)
|
||||
return b"\0\0\0\0"
|
||||
|
@ -39,7 +40,7 @@ def __getattr__(name):
|
|||
# Helpers
|
||||
|
||||
|
||||
def _i(c):
|
||||
def _i(c: bytes) -> int:
|
||||
return i32((b"\0\0\0\0" + c)[-4:])
|
||||
|
||||
|
||||
|
@ -47,13 +48,13 @@ def _i8(c: int | bytes) -> int:
|
|||
return c if isinstance(c, int) else c[0]
|
||||
|
||||
|
||||
def i(c):
|
||||
def i(c: bytes) -> int:
|
||||
""".. deprecated:: 10.2.0"""
|
||||
deprecate("IptcImagePlugin.i", 12)
|
||||
return _i(c)
|
||||
|
||||
|
||||
def dump(c):
|
||||
def dump(c: Sequence[int | bytes]) -> None:
|
||||
""".. deprecated:: 10.2.0"""
|
||||
deprecate("IptcImagePlugin.dump", 12)
|
||||
for i in c:
|
||||
|
@ -70,10 +71,10 @@ class IptcImageFile(ImageFile.ImageFile):
|
|||
format = "IPTC"
|
||||
format_description = "IPTC/NAA"
|
||||
|
||||
def getint(self, key):
|
||||
def getint(self, key: tuple[int, int]) -> int:
|
||||
return _i(self.info[key])
|
||||
|
||||
def field(self):
|
||||
def field(self) -> tuple[tuple[int, int] | None, int]:
|
||||
#
|
||||
# get a IPTC field header
|
||||
s = self.fp.read(5)
|
||||
|
@ -101,7 +102,7 @@ class IptcImageFile(ImageFile.ImageFile):
|
|||
|
||||
return tag, size
|
||||
|
||||
def _open(self):
|
||||
def _open(self) -> None:
|
||||
# load descriptive fields
|
||||
while True:
|
||||
offset = self.fp.tell()
|
||||
|
|
Loading…
Reference in New Issue
Block a user