mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-28 02:46:18 +03:00
Merge remote-tracking branch 'origin/type_hints' into type_hints
This commit is contained in:
commit
007caae02a
13
.github/workflows/test-docker.yml
vendored
13
.github/workflows/test-docker.yml
vendored
|
@ -36,8 +36,8 @@ jobs:
|
||||||
docker: [
|
docker: [
|
||||||
# Run slower jobs first to give them a headstart and reduce waiting time
|
# Run slower jobs first to give them a headstart and reduce waiting time
|
||||||
ubuntu-22.04-jammy-arm64v8,
|
ubuntu-22.04-jammy-arm64v8,
|
||||||
ubuntu-22.04-jammy-ppc64le,
|
ubuntu-24.04-noble-ppc64le,
|
||||||
ubuntu-22.04-jammy-s390x,
|
ubuntu-24.04-noble-s390x,
|
||||||
# Then run the remainder
|
# Then run the remainder
|
||||||
alpine,
|
alpine,
|
||||||
amazon-2-amd64,
|
amazon-2-amd64,
|
||||||
|
@ -52,14 +52,15 @@ jobs:
|
||||||
gentoo,
|
gentoo,
|
||||||
ubuntu-20.04-focal-amd64,
|
ubuntu-20.04-focal-amd64,
|
||||||
ubuntu-22.04-jammy-amd64,
|
ubuntu-22.04-jammy-amd64,
|
||||||
|
ubuntu-24.04-noble-amd64,
|
||||||
]
|
]
|
||||||
dockerTag: [main]
|
dockerTag: [main]
|
||||||
include:
|
include:
|
||||||
- docker: "ubuntu-22.04-jammy-arm64v8"
|
- docker: "ubuntu-22.04-jammy-arm64v8"
|
||||||
qemu-arch: "aarch64"
|
qemu-arch: "aarch64"
|
||||||
- docker: "ubuntu-22.04-jammy-ppc64le"
|
- docker: "ubuntu-24.04-noble-ppc64le"
|
||||||
qemu-arch: "ppc64le"
|
qemu-arch: "ppc64le"
|
||||||
- docker: "ubuntu-22.04-jammy-s390x"
|
- docker: "ubuntu-24.04-noble-s390x"
|
||||||
qemu-arch: "s390x"
|
qemu-arch: "s390x"
|
||||||
|
|
||||||
name: ${{ matrix.docker }}
|
name: ${{ matrix.docker }}
|
||||||
|
@ -81,8 +82,8 @@ jobs:
|
||||||
|
|
||||||
- name: Docker build
|
- name: Docker build
|
||||||
run: |
|
run: |
|
||||||
# The Pillow user in the docker container is UID 1000
|
# The Pillow user in the docker container is UID 1001
|
||||||
sudo chown -R 1000 $GITHUB_WORKSPACE
|
sudo chown -R 1001 $GITHUB_WORKSPACE
|
||||||
docker run --name pillow_container -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }}
|
docker run --name pillow_container -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }}
|
||||||
sudo chown -R runner $GITHUB_WORKSPACE
|
sudo chown -R runner $GITHUB_WORKSPACE
|
||||||
|
|
||||||
|
|
4
.github/workflows/test-valgrind.yml
vendored
4
.github/workflows/test-valgrind.yml
vendored
|
@ -50,7 +50,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build and Run Valgrind
|
- name: Build and Run Valgrind
|
||||||
run: |
|
run: |
|
||||||
# The Pillow user in the docker container is UID 1000
|
# The Pillow user in the docker container is UID 1001
|
||||||
sudo chown -R 1000 $GITHUB_WORKSPACE
|
sudo chown -R 1001 $GITHUB_WORKSPACE
|
||||||
docker run --name pillow_container -e "PILLOW_VALGRIND_TEST=true" -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }}
|
docker run --name pillow_container -e "PILLOW_VALGRIND_TEST=true" -v $GITHUB_WORKSPACE:/Pillow pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }}
|
||||||
sudo chown -R runner $GITHUB_WORKSPACE
|
sudo chown -R runner $GITHUB_WORKSPACE
|
||||||
|
|
|
@ -47,7 +47,9 @@ These platforms are built and tested for every change.
|
||||||
| Ubuntu Linux 22.04 LTS (Jammy) | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
| Ubuntu Linux 22.04 LTS (Jammy) | 3.8, 3.9, 3.10, 3.11, | x86-64 |
|
||||||
| | 3.12, 3.13, PyPy3 | |
|
| | 3.12, 3.13, PyPy3 | |
|
||||||
| +----------------------------+---------------------+
|
| +----------------------------+---------------------+
|
||||||
| | 3.10 | arm64v8, ppc64le, |
|
| | 3.10 | arm64v8 |
|
||||||
|
+----------------------------------+----------------------------+---------------------+
|
||||||
|
| Ubuntu Linux 24.04 LTS (Noble) | 3.12 | x86-64, ppc64le, |
|
||||||
| | | s390x |
|
| | | s390x |
|
||||||
+----------------------------------+----------------------------+---------------------+
|
+----------------------------------+----------------------------+---------------------+
|
||||||
| Windows Server 2016 | 3.8 | x86-64 |
|
| Windows Server 2016 | 3.8 | x86-64 |
|
||||||
|
|
|
@ -41,7 +41,16 @@ import warnings
|
||||||
from collections.abc import Callable, MutableMapping
|
from collections.abc import Callable, MutableMapping
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import IO, TYPE_CHECKING, Any, Literal, Protocol, SupportsInt, cast
|
from typing import (
|
||||||
|
IO,
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Any,
|
||||||
|
Literal,
|
||||||
|
Protocol,
|
||||||
|
Sequence,
|
||||||
|
SupportsInt,
|
||||||
|
cast,
|
||||||
|
)
|
||||||
|
|
||||||
# VERSION was removed in Pillow 6.0.0.
|
# VERSION was removed in Pillow 6.0.0.
|
||||||
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
# PILLOW_VERSION was removed in Pillow 9.0.0.
|
||||||
|
@ -903,7 +912,7 @@ class Image:
|
||||||
return self.im.pixel_access(self.readonly)
|
return self.im.pixel_access(self.readonly)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def verify(self):
|
def verify(self) -> None:
|
||||||
"""
|
"""
|
||||||
Verifies the contents of a file. For data read from a file, this
|
Verifies the contents of a file. For data read from a file, this
|
||||||
method attempts to determine if the file is broken, without
|
method attempts to determine if the file is broken, without
|
||||||
|
@ -1293,7 +1302,9 @@ class Image:
|
||||||
|
|
||||||
return im.crop((x0, y0, x1, y1))
|
return im.crop((x0, y0, x1, y1))
|
||||||
|
|
||||||
def draft(self, mode, size):
|
def draft(
|
||||||
|
self, mode: str, size: tuple[int, int]
|
||||||
|
) -> tuple[str, tuple[int, int, float, float]] | None:
|
||||||
"""
|
"""
|
||||||
Configures the image file loader so it returns a version of the
|
Configures the image file loader so it returns a version of the
|
||||||
image that as closely as possible matches the given mode and
|
image that as closely as possible matches the given mode and
|
||||||
|
@ -1316,7 +1327,7 @@ class Image:
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _expand(self, xmargin, ymargin=None):
|
def _expand(self, xmargin: int, ymargin: int | None = None) -> Image:
|
||||||
if ymargin is None:
|
if ymargin is None:
|
||||||
ymargin = xmargin
|
ymargin = xmargin
|
||||||
self.load()
|
self.load()
|
||||||
|
@ -3477,7 +3488,7 @@ def eval(image, *args):
|
||||||
return image.point(args[0])
|
return image.point(args[0])
|
||||||
|
|
||||||
|
|
||||||
def merge(mode, bands):
|
def merge(mode: str, bands: Sequence[Image]) -> Image:
|
||||||
"""
|
"""
|
||||||
Merge a set of single band images into a new multiband image.
|
Merge a set of single band images into a new multiband image.
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ class ImageFile(Image.Image):
|
||||||
self.tile = []
|
self.tile = []
|
||||||
super().__setstate__(state)
|
super().__setstate__(state)
|
||||||
|
|
||||||
def verify(self):
|
def verify(self) -> None:
|
||||||
"""Check file integrity"""
|
"""Check file integrity"""
|
||||||
|
|
||||||
# raise exception if something's wrong. must be called
|
# raise exception if something's wrong. must be called
|
||||||
|
|
|
@ -424,13 +424,15 @@ class JpegImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def draft(self, mode, size):
|
def draft(
|
||||||
|
self, mode: str, size: tuple[int, int]
|
||||||
|
) -> tuple[str, tuple[int, int, float, float]] | None:
|
||||||
if len(self.tile) != 1:
|
if len(self.tile) != 1:
|
||||||
return
|
return None
|
||||||
|
|
||||||
# Protect from second call
|
# Protect from second call
|
||||||
if self.decoderconfig:
|
if self.decoderconfig:
|
||||||
return
|
return None
|
||||||
|
|
||||||
d, e, o, a = self.tile[0]
|
d, e, o, a = self.tile[0]
|
||||||
scale = 1
|
scale = 1
|
||||||
|
|
|
@ -783,7 +783,7 @@ class PngImageFile(ImageFile.ImageFile):
|
||||||
self.seek(frame)
|
self.seek(frame)
|
||||||
return self._text
|
return self._text
|
||||||
|
|
||||||
def verify(self):
|
def verify(self) -> None:
|
||||||
"""Verify PNG file"""
|
"""Verify PNG file"""
|
||||||
|
|
||||||
if self.fp is None:
|
if self.fp is None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user