Depend on Pillow instead of types-Pillow (#11720)

This commit is contained in:
Sebastian Rittau
2024-04-05 13:30:27 +02:00
committed by GitHub
parent 130a04905c
commit c0a44be33f
10 changed files with 35 additions and 24 deletions

View File

@@ -1,15 +1,20 @@
# Verify that ImageTK images are valid to pass to TK code.
from __future__ import annotations
import tkinter
# The following tests don't work at the moment, due to pyright getting
# confused by the existence of these stubs and annotations in the actual
# Pillow package.
# https://github.com/python/typeshed/issues/11688
from PIL import ImageTk
# import tkinter
photo = ImageTk.PhotoImage()
bitmap = ImageTk.BitmapImage()
# from PIL import ImageTk
tkinter.Label(image=photo)
tkinter.Label(image=bitmap)
# photo = ImageTk.PhotoImage()
# bitmap = ImageTk.BitmapImage()
tkinter.Label().configure(image=photo)
tkinter.Label().configure(image=bitmap)
# tkinter.Label(image=photo)
# tkinter.Label(image=bitmap)
# tkinter.Label().configure(image=photo)
# tkinter.Label().configure(image=bitmap)

View File

@@ -3,14 +3,14 @@ import tkinter
from _typeshed import ReadableBuffer, StrOrBytesPath, SupportsRead
from typing import Any
from PIL.Image import Image, _Mode, _Size
from PIL.Image import Image
class PhotoImage(tkinter._PhotoImageLike):
tk: _tkinter.TkappType
def __init__(
self,
image: Image | _Mode | None = None,
size: _Size | None = None,
image: Image | str | None = None,
size: tuple[int, int] | None = None,
*,
file: StrOrBytesPath | SupportsRead[bytes] = ...,
data: ReadableBuffer = ...,

View File

@@ -1,9 +1,16 @@
from _typeshed import Incomplete
from PIL._imaging import _PixelAccessor
from typing import Protocol
ffi: Incomplete
# Copy of PIL._imaging.PixelAccess.
# See https://github.com/python/typeshed/issues/11688.
class _PixelAccessor(Protocol):
def __setitem__(self, xy: tuple[int, int], color, /) -> None: ...
def __getitem__(self, xy: tuple[int, int], /): ...
def putpixel(self, xy: tuple[int, int], color, /) -> None: ...
def getpixel(self, xy: tuple[int, int], /): ...
class PyAccess(_PixelAccessor):
readonly: Incomplete
image8: Incomplete

View File

@@ -1,3 +1,3 @@
version = "0.9.*"
upstream_repository = "https://github.com/asweigart/pyautogui"
requires = ["types-Pillow", "types-PyScreeze"]
requires = ["types-PyScreeze"]

View File

@@ -1,6 +1,6 @@
version = "0.1.30"
upstream_repository = "https://github.com/asweigart/pyscreeze"
requires = ["types-Pillow"]
requires = ["Pillow>=10.3.0"]
[tool.stubtest]
# Linux has extra constants, win32 has different definitions

View File

@@ -1,6 +1,6 @@
version = "2.7.8"
upstream_repository = "https://github.com/PyFPDF/fpdf2"
requires = ["types-Pillow>=9.2.0"]
requires = ["Pillow>=10.3.0"]
[tool.stubtest]
stubtest_requirements = ["cryptography"]

View File

@@ -1,3 +1,2 @@
version = "0.33.*"
upstream_repository = "https://github.com/python-xlib/python-xlib"
requires = ["types-Pillow"]

View File

@@ -1,12 +1,14 @@
from collections.abc import Iterable, Sequence
from typing import Any
from typing_extensions import TypeAlias
from PIL import Image
from Xlib._typing import ErrorHandler
from Xlib.protocol import request, rq
from Xlib.protocol.structs import _Arc6IntSequence, _Rectangle4IntSequence, _RGB3IntIterable, _Segment4IntSequence
from Xlib.xobject import colormap, cursor, fontable, resource
_Image: TypeAlias = Any # PIL.Image.Image
class Drawable(resource.Resource):
__drawable__ = resource.Resource.__resource__
def get_geometry(self) -> request.GetGeometry: ...
@@ -100,7 +102,7 @@ class Drawable(resource.Resource):
data: bytes | bytearray,
onerror: ErrorHandler[object] | None = None,
) -> None: ...
def put_pil_image(self, gc: int, x: int, y: int, image: Image.Image, onerror: ErrorHandler[object] | None = None) -> None: ...
def put_pil_image(self, gc: int, x: int, y: int, image: _Image, onerror: ErrorHandler[object] | None = None) -> None: ...
def get_image(self, x: int, y: int, width: int, height: int, format: int, plane_mask: int) -> request.GetImage: ...
def draw_text(
self, gc: int, x: int, y: int, text: dict[str, str | int], onerror: ErrorHandler[object] | None = None