From ffd0363b65ca05870f9306e8a6e999d58d9725ae Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 13 Jan 2024 16:26:15 +1100 Subject: [PATCH] Added type hints --- src/PIL/FitsImagePlugin.py | 8 +++++--- src/PIL/Image.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/PIL/FitsImagePlugin.py b/src/PIL/FitsImagePlugin.py index 7dce2d60f76..e69890babcc 100644 --- a/src/PIL/FitsImagePlugin.py +++ b/src/PIL/FitsImagePlugin.py @@ -15,7 +15,7 @@ from . import Image, ImageFile -def _accept(prefix): +def _accept(prefix: bytes) -> bool: return prefix[:6] == b"SIMPLE" @@ -23,8 +23,10 @@ class FitsImageFile(ImageFile.ImageFile): format = "FITS" format_description = "FITS" - def _open(self): - headers = {} + def _open(self) -> None: + assert self.fp is not None + + headers: dict[bytes, bytes] = {} while True: header = self.fp.read(80) if not header: diff --git a/src/PIL/Image.py b/src/PIL/Image.py index ac13c6c0c25..b2520d57c5a 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -3484,7 +3484,7 @@ def register_extension(id, extension) -> None: EXTENSION[extension.lower()] = id.upper() -def register_extensions(id, extensions): +def register_extensions(id, extensions) -> None: """ Registers image extensions. This function should not be used in application code.