Skip to content

Commit 9077c2c

Browse files
committed
ImageFile context manager value is typed in Pillow >= 12.1.0
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
1 parent 523fbb6 commit 9077c2c

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
hooks:
5959
- id: mypy
6060
name: Check Python types
61-
additional_dependencies: [flask, openslide-bin, pillow, types-PyYAML, types-setuptools]
61+
additional_dependencies: [flask, openslide-bin, pillow >= 12.1.0, types-PyYAML, types-setuptools]
6262

6363
- repo: https://github.com/rstcheck/rstcheck
6464
rev: v6.2.5

openslide/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,7 @@ def detect_format(cls, filename: lowlevel.Filename) -> str | None:
394394
If the file format is not recognized, return None."""
395395
try:
396396
with Image.open(filename) as img:
397-
# img currently resolves as Any
398-
# https://github.com/python-pillow/Pillow/pull/8362
399-
return img.format # type: ignore[no-any-return]
397+
return img.format
400398
except OSError:
401399
return None
402400

0 commit comments

Comments
 (0)