Fix mypy/CI mismatch: drop obsolete types-Pillow stubs
Pillow >=9.2 ships its own inline types (py.typed), which the separate types-Pillow stub package shadows when both are installed. Since types-Pillow lived in the `test` dependency group (not `dev`), a local `uv sync --group dev --group test` env had it installed and mypy silently preferred its stubs, while CI's lint job only syncs the default `dev` group and used Pillow's own (correct) stubs - surfacing 5 real "Incompatible types in assignment" errors that never appeared locally. Fixed the underlying type errors in _pipeline.py and ghostscript.py: `im` was inferred as ImageFile.ImageFile from `Image.open(...) as im`, but later reassigned the result of `.resize()`/`.transpose()`, which return the broader Image.Image - now declared explicitly as `im: Image.Image` before the `with` block.
This commit is contained in:
@@ -186,7 +186,6 @@ test = [
|
||||
"python-xmp-toolkit==2.0.1", # also requires apt-get install libexempi3
|
||||
"reportlab>=3.6.8",
|
||||
# Type stubs for testing
|
||||
"types-Pillow",
|
||||
"types-humanfriendly",
|
||||
# Extended test capabilities (merged from extended_test)
|
||||
"pymupdf>=1.24.14",
|
||||
|
||||
@@ -209,6 +209,7 @@ def rasterize_pdf(
|
||||
)
|
||||
|
||||
try:
|
||||
im: Image.Image
|
||||
with Image.open(output_file) as im:
|
||||
if needs_low_dpi_resize:
|
||||
# Resize to the dimensions that would have resulted from the
|
||||
|
||||
@@ -683,6 +683,7 @@ def create_ocr_image(image: Path, page_context: PageContext) -> Path:
|
||||
"""
|
||||
output_file = page_context.get_path('ocr.png')
|
||||
options = page_context.options
|
||||
im: Image.Image
|
||||
with Image.open(image) as im:
|
||||
log.debug('resolution %r', im.info['dpi'])
|
||||
|
||||
|
||||
@@ -1483,7 +1483,6 @@ test = [
|
||||
{ name = "python-xmp-toolkit" },
|
||||
{ name = "reportlab" },
|
||||
{ name = "types-humanfriendly" },
|
||||
{ name = "types-pillow" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
@@ -1540,7 +1539,6 @@ test = [
|
||||
{ name = "python-xmp-toolkit", specifier = "==2.0.1" },
|
||||
{ name = "reportlab", specifier = ">=3.6.8" },
|
||||
{ name = "types-humanfriendly" },
|
||||
{ name = "types-pillow" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3086,15 +3084,6 @@ wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/2c/9f/694f2a833cda25f633c0c53e1d9e65a8a46b887ed4dd30f20de22e7100ee/types_humanfriendly-10.0.1.20250319-py3-none-any.whl", hash = "sha256:0fec93cc793b91309481ed4bb9bed178ffde0076026fb3ac1cc3299ad7ecbc46", size = 14835, upload-time = "2025-03-19T02:52:17.906Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "types-pillow"
|
||||
version = "10.2.0.20240822"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/18/4a/4495264dddaa600d65d68bcedb64dcccf9d9da61adff51f7d2ffd8e4c9ce/types-Pillow-10.2.0.20240822.tar.gz", hash = "sha256:559fb52a2ef991c326e4a0d20accb3bb63a7ba8d40eb493e0ecb0310ba52f0d3", size = 35389, upload-time = "2024-08-22T02:32:48.15Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/66/23/e81a5354859831fcf54d488d33b80ba6133ea84f874a9c0ec40a4881e133/types_Pillow-10.2.0.20240822-py3-none-any.whl", hash = "sha256:d9dab025aba07aeb12fd50a6799d4eac52a9603488eca09d7662543983f16c5d", size = 54354, upload-time = "2024-08-22T02:32:46.664Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "4.15.0"
|
||||
|
||||
Reference in New Issue
Block a user