Skip to content

Commit c0a44be

Browse files
authored
Depend on Pillow instead of types-Pillow (#11720)
1 parent 130a049 commit c0a44be

File tree

10 files changed

+35
-24
lines changed

10 files changed

+35
-24
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ jobs:
123123
if [ -n "$DEPENDENCIES" ]; then
124124
source .venv/bin/activate
125125
echo "Installing packages: $DEPENDENCIES"
126-
# https://github.com/python/typeshed/issues/11688
127-
echo "Pillow<10.3" > constraints.txt
128-
uv pip install -c constraints.txt $DEPENDENCIES
126+
uv pip install $DEPENDENCIES
129127
fi
130128
- name: Activate the isolated venv for the rest of the job
131129
run: echo "$PWD/.venv/bin" >> $GITHUB_PATH

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ If you're just using a type checker ([mypy](https://github.com/python/mypy/),
3131
developing it, you don't need to interact with the typeshed repo at
3232
all: a copy of standard library part of typeshed is bundled with type checkers.
3333
And type stubs for third party packages and modules you are using can
34-
be installed from PyPI. For example, if you are using `Pillow` and `requests`,
34+
be installed from PyPI. For example, if you are using `html5lib` and `requests`,
3535
you can install the type stubs using
3636

3737
```bash
38-
$ pip install types-Pillow types-requests
38+
$ pip install types-html5lib types-requests
3939
```
4040

4141
These PyPI packages follow [PEP 561](http://www.python.org/dev/peps/pep-0561/)
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Verify that ImageTK images are valid to pass to TK code.
22
from __future__ import annotations
33

4-
import tkinter
4+
# The following tests don't work at the moment, due to pyright getting
5+
# confused by the existence of these stubs and annotations in the actual
6+
# Pillow package.
7+
# https://github.com/python/typeshed/issues/11688
58

6-
from PIL import ImageTk
9+
# import tkinter
710

8-
photo = ImageTk.PhotoImage()
9-
bitmap = ImageTk.BitmapImage()
11+
# from PIL import ImageTk
1012

11-
tkinter.Label(image=photo)
12-
tkinter.Label(image=bitmap)
13+
# photo = ImageTk.PhotoImage()
14+
# bitmap = ImageTk.BitmapImage()
1315

14-
tkinter.Label().configure(image=photo)
15-
tkinter.Label().configure(image=bitmap)
16+
# tkinter.Label(image=photo)
17+
# tkinter.Label(image=bitmap)
18+
19+
# tkinter.Label().configure(image=photo)
20+
# tkinter.Label().configure(image=bitmap)

stubs/Pillow/PIL/ImageTk.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import tkinter
33
from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsRead
44
from typing import Any
55

6-
from PIL.Image import Image, _Mode, _Size
6+
from PIL.Image import Image
77

88
class PhotoImage(tkinter._PhotoImageLike):
99
tk: _tkinter.TkappType
1010
def __init__(
1111
self,
12-
image: Image | _Mode | None = None,
13-
size: _Size | None = None,
12+
image: Image | str | None = None,
13+
size: tuple[int, int] | None = None,
1414
*,
1515
file: StrOrBytesPath | SupportsRead[bytes] = ...,
1616
data: ReadableBuffer = ...,

stubs/Pillow/PIL/PyAccess.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
from _typeshed import Incomplete
2-
3-
from PIL._imaging import _PixelAccessor
2+
from typing import Protocol
43

54
ffi: Incomplete
65

6+
# Copy of PIL._imaging.PixelAccess.
7+
# See https://github.com/python/typeshed/issues/11688.
8+
class _PixelAccessor(Protocol):
9+
def __setitem__(self, xy: tuple[int, int], color, /) -> None: ...
10+
def __getitem__(self, xy: tuple[int, int], /): ...
11+
def putpixel(self, xy: tuple[int, int], color, /) -> None: ...
12+
def getpixel(self, xy: tuple[int, int], /): ...
13+
714
class PyAccess(_PixelAccessor):
815
readonly: Incomplete
916
image8: Incomplete

stubs/PyAutoGUI/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "0.9.*"
22
upstream_repository = "https://github.com/asweigart/pyautogui"
3-
requires = ["types-Pillow", "types-PyScreeze"]
3+
requires = ["types-PyScreeze"]

stubs/PyScreeze/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = "0.1.30"
22
upstream_repository = "https://github.com/asweigart/pyscreeze"
3-
requires = ["types-Pillow"]
3+
requires = ["Pillow>=10.3.0"]
44

55
[tool.stubtest]
66
# Linux has extra constants, win32 has different definitions

stubs/fpdf2/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = "2.7.8"
22
upstream_repository = "https://github.com/PyFPDF/fpdf2"
3-
requires = ["types-Pillow>=9.2.0"]
3+
requires = ["Pillow>=10.3.0"]
44

55
[tool.stubtest]
66
stubtest_requirements = ["cryptography"]

stubs/python-xlib/METADATA.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
version = "0.33.*"
22
upstream_repository = "https://github.com/python-xlib/python-xlib"
3-
requires = ["types-Pillow"]

stubs/python-xlib/Xlib/xobject/drawable.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from collections.abc import Iterable, Sequence
22
from typing import Any
3+
from typing_extensions import TypeAlias
34

4-
from PIL import Image
55
from Xlib._typing import ErrorHandler
66
from Xlib.protocol import request, rq
77
from Xlib.protocol.structs import _Arc6IntSequence, _Rectangle4IntSequence, _RGB3IntIterable, _Segment4IntSequence
88
from Xlib.xobject import colormap, cursor, fontable, resource
99

10+
_Image: TypeAlias = Any # PIL.Image.Image
11+
1012
class Drawable(resource.Resource):
1113
__drawable__ = resource.Resource.__resource__
1214
def get_geometry(self) -> request.GetGeometry: ...
@@ -100,7 +102,7 @@ class Drawable(resource.Resource):
100102
data: bytes | bytearray,
101103
onerror: ErrorHandler[object] | None = None,
102104
) -> None: ...
103-
def put_pil_image(self, gc: int, x: int, y: int, image: Image.Image, onerror: ErrorHandler[object] | None = None) -> None: ...
105+
def put_pil_image(self, gc: int, x: int, y: int, image: _Image, onerror: ErrorHandler[object] | None = None) -> None: ...
104106
def get_image(self, x: int, y: int, width: int, height: int, format: int, plane_mask: int) -> request.GetImage: ...
105107
def draw_text(
106108
self, gc: int, x: int, y: int, text: dict[str, str | int], onerror: ErrorHandler[object] | None = None

0 commit comments

Comments
 (0)