From 5c90522e69999d866567ef66d2ffdaf2dfd274db Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 9 Aug 2021 14:20:13 -0700 Subject: [PATCH] mypy: Add types-Pillow. Signed-off-by: Anders Kaseorg --- pyproject.toml | 1 - requirements/dev.txt | 4 ++++ requirements/mypy.in | 1 + requirements/mypy.txt | 4 ++++ version.py | 2 +- zerver/lib/upload.py | 5 ++++- 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7613fba4fc..6efefc5666 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,6 @@ module = [ "onelogin.*", "openapi_core.*", "openapi_schema_validator.*", - "PIL.*", "premailer.*", "psycopg2.*", "pyinotify.*", diff --git a/requirements/dev.txt b/requirements/dev.txt index 8934cf87ec..910786296c 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1688,6 +1688,10 @@ types-orjson==0.1.1 \ --hash=sha256:7454bfbaed27900a844bb9d8e211b69f1c335f0b9e3541d4950a793db41c104d \ --hash=sha256:92f85986261ea1a5cb215e4b35e4016631d35163a372f023918750f340ea737f # via -r requirements/mypy.in +types-pillow==8.3.2 \ + --hash=sha256:35fa2085164e550ef89d10c75963c5c9d673e8fd529343560b945eb6ac26891d \ + --hash=sha256:7926e2d0a774184af16115207a4938b3d1089b3cfac658e837af6a6d2ed8cc2d + # via -r requirements/mypy.in types-polib==0.1.3 \ --hash=sha256:54fb4d5a9edc2b2f7e3cd7ebbf8631dbcecdeb69e9e31597e81c2b5b3bd3613b \ --hash=sha256:bd79bc1780e5d7fb6fd0dce59bb8d118ca81f8b2f14d5d05e21d2716e2e1937b diff --git a/requirements/mypy.in b/requirements/mypy.in index 98ad465199..194325ac25 100644 --- a/requirements/mypy.in +++ b/requirements/mypy.in @@ -18,6 +18,7 @@ types-Markdown types-oauthlib types-orjson types-polib +types-Pillow types-Pygments types-python-dateutil types-pytz diff --git a/requirements/mypy.txt b/requirements/mypy.txt index 92b70b7b68..2b1bfb33fb 100644 --- a/requirements/mypy.txt +++ b/requirements/mypy.txt @@ -129,6 +129,10 @@ types-orjson==0.1.1 \ --hash=sha256:7454bfbaed27900a844bb9d8e211b69f1c335f0b9e3541d4950a793db41c104d \ --hash=sha256:92f85986261ea1a5cb215e4b35e4016631d35163a372f023918750f340ea737f # via -r requirements/mypy.in +types-pillow==8.3.2 \ + --hash=sha256:35fa2085164e550ef89d10c75963c5c9d673e8fd529343560b945eb6ac26891d \ + --hash=sha256:7926e2d0a774184af16115207a4938b3d1089b3cfac658e837af6a6d2ed8cc2d + # via -r requirements/mypy.in types-polib==0.1.3 \ --hash=sha256:54fb4d5a9edc2b2f7e3cd7ebbf8631dbcecdeb69e9e31597e81c2b5b3bd3613b \ --hash=sha256:bd79bc1780e5d7fb6fd0dce59bb8d118ca81f8b2f14d5d05e21d2716e2e1937b diff --git a/version.py b/version.py index 5fee987203..f184106284 100644 --- a/version.py +++ b/version.py @@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 92 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = "153.10" +PROVISION_VERSION = "153.11" diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index 7f58f7ed90..4c40e1133e 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -148,7 +148,9 @@ def resize_gif(im: GifImageFile, size: int = DEFAULT_EMOJI_SIZE) -> bytes: new_frame = ImageOps.pad(new_frame, (size, size), Image.ANTIALIAS) frames.append(new_frame) duration_info.append(im.info["duration"]) - disposals.append(im.disposal_method) + disposals.append( + im.disposal_method # type: ignore[attr-defined] # private member missing from stubs + ) out = io.BytesIO() frames[0].save( out, @@ -168,6 +170,7 @@ def resize_emoji(image_data: bytes, size: int = DEFAULT_EMOJI_SIZE) -> bytes: im = Image.open(io.BytesIO(image_data)) image_format = im.format if image_format == "GIF": + assert isinstance(im, GifImageFile) # There are a number of bugs in Pillow.GifImagePlugin which cause # results in resized gifs being broken. To work around this we # only resize under certain conditions to minimize the chance of