[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
0c2dc2047e
commit
7fc49a5cf4
@ -62,7 +62,6 @@ optional-dependencies.test-arrow = [
|
||||
"nanoarrow",
|
||||
"pyarrow",
|
||||
]
|
||||
|
||||
optional-dependencies.tests = [
|
||||
"check-manifest",
|
||||
"coverage>=7.4.2",
|
||||
@ -77,16 +76,15 @@ optional-dependencies.tests = [
|
||||
"pytest-xdist",
|
||||
"trove-classifiers>=2024.10.12",
|
||||
]
|
||||
|
||||
optional-dependencies.xmp = [
|
||||
"defusedxml",
|
||||
]
|
||||
urls."Release notes" = "https://pillow.readthedocs.io/en/stable/releasenotes/index.html"
|
||||
urls.Changelog = "https://github.com/python-pillow/Pillow/releases"
|
||||
urls.Documentation = "https://pillow.readthedocs.io"
|
||||
urls.Funding = "https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi-pillow&utm_medium=pypi"
|
||||
urls.Homepage = "https://python-pillow.github.io"
|
||||
urls.Mastodon = "https://fosstodon.org/@pillow"
|
||||
urls."Release notes" = "https://pillow.readthedocs.io/en/stable/releasenotes/index.html"
|
||||
urls.Source = "https://github.com/python-pillow/Pillow"
|
||||
|
||||
[tool.setuptools]
|
||||
@ -95,70 +93,50 @@ packages = [
|
||||
]
|
||||
include-package-data = true
|
||||
package-dir = { "" = "src" }
|
||||
|
||||
[tool.setuptools.dynamic]
|
||||
version = { attr = "PIL.__version__" }
|
||||
dynamic.version = { attr = "PIL.__version__" }
|
||||
|
||||
[tool.cibuildwheel]
|
||||
before-all = ".github/workflows/wheels-dependencies.sh"
|
||||
build-verbosity = 1
|
||||
|
||||
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable"
|
||||
|
||||
test-command = "cd {project} && .github/workflows/wheels-test.sh"
|
||||
test-extras = "tests"
|
||||
test-requires = [
|
||||
"numpy",
|
||||
]
|
||||
xbuild-tools = [ ]
|
||||
|
||||
[tool.cibuildwheel.ios]
|
||||
xbuild-tools = []
|
||||
# Disable platform guessing on iOS, and disable raqm (since there won't be a
|
||||
# vendor version, and we can't distribute it due to licensing)
|
||||
config-settings = "raqm=disable imagequant=disable platform-guessing=disable"
|
||||
|
||||
ios.config-settings = "raqm=disable imagequant=disable platform-guessing=disable"
|
||||
# iOS needs to be given a specific pytest invocation and list of test sources.
|
||||
test-sources = [
|
||||
ios.test-sources = [
|
||||
"checks",
|
||||
"Tests",
|
||||
"selftest.py",
|
||||
]
|
||||
test-command = [
|
||||
ios.test-command = [
|
||||
"python -m selftest",
|
||||
"python -m pytest -vv -x -W always checks/check_wheel.py Tests",
|
||||
]
|
||||
|
||||
# There's no numpy wheel for iOS (yet...)
|
||||
test-requires = [ ]
|
||||
|
||||
[tool.cibuildwheel.macos]
|
||||
ios.test-requires = []
|
||||
# Disable platform guessing on macOS to avoid picking up Homebrew etc.
|
||||
config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable platform-guessing=disable"
|
||||
|
||||
[tool.cibuildwheel.macos.environment]
|
||||
macos.config-settings = "raqm=enable raqm=vendor fribidi=vendor imagequant=disable platform-guessing=disable"
|
||||
# Isolate macOS build environment from Homebrew etc.
|
||||
PATH = "$(pwd)/build/deps/darwin/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
|
||||
|
||||
[[tool.cibuildwheel.overrides]]
|
||||
# iOS environment is isolated by cibuildwheel, but needs the dependencies
|
||||
select = "*_iphoneos"
|
||||
environment.PATH = "$(pwd)/build/deps/iphoneos/bin:$PATH"
|
||||
|
||||
[[tool.cibuildwheel.overrides]]
|
||||
# iOS simulator environment is isolated by cibuildwheel, but needs the dependencies
|
||||
select = "*_iphonesimulator"
|
||||
environment.PATH = "$(pwd)/build/deps/iphonesimulator/bin:$PATH"
|
||||
|
||||
[[tool.cibuildwheel.overrides]]
|
||||
select = "*-win32"
|
||||
test-requires = [ ]
|
||||
macos.environment.PATH = "$(pwd)/build/deps/darwin/bin:$(dirname $(which python3)):/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
|
||||
overrides = [
|
||||
# iOS environment is isolated by cibuildwheel, but needs the dependencies
|
||||
{ select = "*_iphoneos", environment.PATH = "$(pwd)/build/deps/iphoneos/bin:$PATH" },
|
||||
# iOS simulator environment is isolated by cibuildwheel, but needs the dependencies
|
||||
{ select = "*_iphonesimulator", environment.PATH = "$(pwd)/build/deps/iphonesimulator/bin:$PATH" },
|
||||
{ select = "*-win32", test-requires = [] },
|
||||
]
|
||||
|
||||
[tool.black]
|
||||
exclude = "wheels/multibuild"
|
||||
|
||||
[tool.ruff]
|
||||
exclude = [ "wheels/multibuild" ]
|
||||
|
||||
fix = true
|
||||
lint.select = [
|
||||
"C4", # flake8-comprehensions
|
||||
@ -207,9 +185,9 @@ lint.isort.required-imports = [
|
||||
[tool.pyproject-fmt]
|
||||
max_supported_python = "3.14"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "-ra --color=auto"
|
||||
testpaths = [
|
||||
[tool.pytest]
|
||||
ini_options.addopts = "-ra --color=auto"
|
||||
ini_options.testpaths = [
|
||||
"Tests",
|
||||
]
|
||||
|
||||
|
||||
@ -124,8 +124,10 @@ PyImagingPhotoPut(
|
||||
if (im->mode == IMAGING_MODE_1 || im->mode == IMAGING_MODE_L) {
|
||||
block.pixelSize = 1;
|
||||
block.offset[0] = block.offset[1] = block.offset[2] = block.offset[3] = 0;
|
||||
} else if (im->mode == IMAGING_MODE_RGB || im->mode == IMAGING_MODE_RGBA ||
|
||||
im->mode == IMAGING_MODE_RGBX || im->mode == IMAGING_MODE_RGBa) {
|
||||
} else if (
|
||||
im->mode == IMAGING_MODE_RGB || im->mode == IMAGING_MODE_RGBA ||
|
||||
im->mode == IMAGING_MODE_RGBX || im->mode == IMAGING_MODE_RGBa
|
||||
) {
|
||||
block.pixelSize = 4;
|
||||
block.offset[0] = 0;
|
||||
block.offset[1] = 1;
|
||||
|
||||
@ -999,8 +999,9 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||
status = ImagingLibTiffSetField(
|
||||
&encoder->state, (ttag_t)key_int, PyBytes_AsString(value)
|
||||
);
|
||||
} else if (type == TIFF_DOUBLE || type == TIFF_SRATIONAL ||
|
||||
type == TIFF_RATIONAL) {
|
||||
} else if (
|
||||
type == TIFF_DOUBLE || type == TIFF_SRATIONAL || type == TIFF_RATIONAL
|
||||
) {
|
||||
status = ImagingLibTiffSetField(
|
||||
&encoder->state, (ttag_t)key_int, (FLOAT64)PyFloat_AsDouble(value)
|
||||
);
|
||||
|
||||
@ -170,16 +170,17 @@ export_named_type(struct ArrowSchema *schema, char *format, const char *name) {
|
||||
strncpy(formatp, format, format_len);
|
||||
strncpy(namep, name, name_len);
|
||||
|
||||
*schema = (struct ArrowSchema){// Type description
|
||||
.format = formatp,
|
||||
.name = namep,
|
||||
.metadata = NULL,
|
||||
.flags = 0,
|
||||
.n_children = 0,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &ReleaseExportedSchema
|
||||
*schema = (struct ArrowSchema){
|
||||
// Type description
|
||||
.format = formatp,
|
||||
.name = namep,
|
||||
.metadata = NULL,
|
||||
.flags = 0,
|
||||
.n_children = 0,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &ReleaseExportedSchema
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
@ -287,17 +288,18 @@ export_single_channel_array(Imaging im, struct ArrowArray *array) {
|
||||
im->refcount++;
|
||||
MUTEX_UNLOCK(&im->mutex);
|
||||
// Initialize primitive fields
|
||||
*array = (struct ArrowArray){// Data description
|
||||
.length = length,
|
||||
.offset = 0,
|
||||
.null_count = 0,
|
||||
.n_buffers = 2,
|
||||
.n_children = 0,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &release_const_array,
|
||||
.private_data = im
|
||||
*array = (struct ArrowArray){
|
||||
// Data description
|
||||
.length = length,
|
||||
.offset = 0,
|
||||
.null_count = 0,
|
||||
.n_buffers = 2,
|
||||
.n_children = 0,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &release_const_array,
|
||||
.private_data = im
|
||||
};
|
||||
|
||||
// Allocate list of buffers
|
||||
@ -332,17 +334,18 @@ export_fixed_pixel_array(Imaging im, struct ArrowArray *array) {
|
||||
// Initialize primitive fields
|
||||
// Fixed length arrays are 1 buffer of validity, and the length in pixels.
|
||||
// Data is in a child array.
|
||||
*array = (struct ArrowArray){// Data description
|
||||
.length = length,
|
||||
.offset = 0,
|
||||
.null_count = 0,
|
||||
.n_buffers = 1,
|
||||
.n_children = 1,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &release_const_array,
|
||||
.private_data = im
|
||||
*array = (struct ArrowArray){
|
||||
// Data description
|
||||
.length = length,
|
||||
.offset = 0,
|
||||
.null_count = 0,
|
||||
.n_buffers = 1,
|
||||
.n_children = 1,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &release_const_array,
|
||||
.private_data = im
|
||||
};
|
||||
|
||||
// Allocate list of buffers
|
||||
@ -367,17 +370,18 @@ export_fixed_pixel_array(Imaging im, struct ArrowArray *array) {
|
||||
MUTEX_LOCK(&im->mutex);
|
||||
im->refcount++;
|
||||
MUTEX_UNLOCK(&im->mutex);
|
||||
*array->children[0] = (struct ArrowArray){// Data description
|
||||
.length = length * 4,
|
||||
.offset = 0,
|
||||
.null_count = 0,
|
||||
.n_buffers = 2,
|
||||
.n_children = 0,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &release_const_array,
|
||||
.private_data = im
|
||||
*array->children[0] = (struct ArrowArray){
|
||||
// Data description
|
||||
.length = length * 4,
|
||||
.offset = 0,
|
||||
.null_count = 0,
|
||||
.n_buffers = 2,
|
||||
.n_children = 0,
|
||||
.children = NULL,
|
||||
.dictionary = NULL,
|
||||
// Bookkeeping
|
||||
.release = &release_const_array,
|
||||
.private_data = im
|
||||
};
|
||||
|
||||
array->children[0]->buffers =
|
||||
|
||||
@ -1695,16 +1695,20 @@ ImagingConvertTransparent(Imaging imIn, const ModeID mode, int r, int g, int b)
|
||||
if (mode == IMAGING_MODE_RGBa) {
|
||||
premultiplied = 1;
|
||||
}
|
||||
} else if (imIn->mode == IMAGING_MODE_RGB &&
|
||||
(mode == IMAGING_MODE_LA || mode == IMAGING_MODE_La)) {
|
||||
} else if (
|
||||
imIn->mode == IMAGING_MODE_RGB &&
|
||||
(mode == IMAGING_MODE_LA || mode == IMAGING_MODE_La)
|
||||
) {
|
||||
convert = rgb2la;
|
||||
source_transparency = 1;
|
||||
if (mode == IMAGING_MODE_La) {
|
||||
premultiplied = 1;
|
||||
}
|
||||
} else if ((imIn->mode == IMAGING_MODE_1 || imIn->mode == IMAGING_MODE_I ||
|
||||
imIn->mode == IMAGING_MODE_I_16 || imIn->mode == IMAGING_MODE_L) &&
|
||||
(mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_LA)) {
|
||||
} else if (
|
||||
(imIn->mode == IMAGING_MODE_1 || imIn->mode == IMAGING_MODE_I ||
|
||||
imIn->mode == IMAGING_MODE_I_16 || imIn->mode == IMAGING_MODE_L) &&
|
||||
(mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_LA)
|
||||
) {
|
||||
if (imIn->mode == IMAGING_MODE_1) {
|
||||
convert = bit2rgb;
|
||||
} else if (imIn->mode == IMAGING_MODE_I) {
|
||||
|
||||
@ -537,8 +537,9 @@ polygon_generic(
|
||||
// Needed to draw consistent polygons
|
||||
xx[j] = xx[j - 1];
|
||||
j++;
|
||||
} else if ((ymin == current->ymin || ymin == current->ymax) &&
|
||||
current->dx != 0) {
|
||||
} else if (
|
||||
(ymin == current->ymin || ymin == current->ymax) && current->dx != 0
|
||||
) {
|
||||
// Connect discontiguous corners
|
||||
for (k = 0; k < i; k++) {
|
||||
Edge *other_edge = edge_table[k];
|
||||
@ -570,8 +571,10 @@ polygon_generic(
|
||||
adjacent_line_x, adjacent_line_x_other_edge
|
||||
)) +
|
||||
1;
|
||||
} else if (xx[j - 1] < adjacent_line_x - 1 &&
|
||||
xx[j - 1] < adjacent_line_x_other_edge - 1) {
|
||||
} else if (
|
||||
xx[j - 1] < adjacent_line_x - 1 &&
|
||||
xx[j - 1] < adjacent_line_x_other_edge - 1
|
||||
) {
|
||||
xx[j - 1] =
|
||||
roundf(fmin(
|
||||
adjacent_line_x, adjacent_line_x_other_edge
|
||||
|
||||
@ -89,10 +89,12 @@ ImagingGetBBox(Imaging im, int bbox[4], int alpha_only) {
|
||||
INT32 mask = 0xffffffff;
|
||||
if (im->bands == 3) {
|
||||
((UINT8 *)&mask)[3] = 0;
|
||||
} else if (alpha_only &&
|
||||
(im->mode == IMAGING_MODE_RGBa || im->mode == IMAGING_MODE_RGBA ||
|
||||
im->mode == IMAGING_MODE_La || im->mode == IMAGING_MODE_LA ||
|
||||
im->mode == IMAGING_MODE_PA)) {
|
||||
} else if (
|
||||
alpha_only &&
|
||||
(im->mode == IMAGING_MODE_RGBa || im->mode == IMAGING_MODE_RGBA ||
|
||||
im->mode == IMAGING_MODE_La || im->mode == IMAGING_MODE_LA ||
|
||||
im->mode == IMAGING_MODE_PA)
|
||||
) {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
mask = 0x000000ff;
|
||||
#else
|
||||
|
||||
@ -330,8 +330,10 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) {
|
||||
components = 4;
|
||||
color_space = OPJ_CLRSPC_SRGB;
|
||||
pack = j2k_pack_rgba;
|
||||
#if ((OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 5 && OPJ_VERSION_BUILD >= 3) || \
|
||||
(OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR > 5) || OPJ_VERSION_MAJOR > 2)
|
||||
#if ( \
|
||||
(OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 5 && OPJ_VERSION_BUILD >= 3) || \
|
||||
(OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR > 5) || OPJ_VERSION_MAJOR > 2 \
|
||||
)
|
||||
} else if (im->mode == IMAGING_MODE_CMYK) {
|
||||
components = 4;
|
||||
color_space = OPJ_CLRSPC_CMYK;
|
||||
|
||||
@ -206,8 +206,10 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t by
|
||||
context->cinfo.out_color_space = JCS_EXT_RGBX;
|
||||
}
|
||||
#endif
|
||||
else if (context->rawmode == IMAGING_RAWMODE_CMYK ||
|
||||
context->rawmode == IMAGING_RAWMODE_CMYK_I) {
|
||||
else if (
|
||||
context->rawmode == IMAGING_RAWMODE_CMYK ||
|
||||
context->rawmode == IMAGING_RAWMODE_CMYK_I
|
||||
) {
|
||||
context->cinfo.out_color_space = JCS_CMYK;
|
||||
} else if (context->rawmode == IMAGING_RAWMODE_YCbCr) {
|
||||
context->cinfo.out_color_space = JCS_YCbCr;
|
||||
|
||||
@ -46,8 +46,9 @@ ImagingConvertMatrix(Imaging im, const ModeID mode, float m[]) {
|
||||
}
|
||||
}
|
||||
ImagingSectionLeave(&cookie);
|
||||
} else if (mode == IMAGING_MODE_HSV || mode == IMAGING_MODE_LAB ||
|
||||
mode == IMAGING_MODE_RGB) {
|
||||
} else if (
|
||||
mode == IMAGING_MODE_HSV || mode == IMAGING_MODE_LAB || mode == IMAGING_MODE_RGB
|
||||
) {
|
||||
imOut = ImagingNewDirty(mode, im->xsize, im->ysize);
|
||||
if (!imOut) {
|
||||
return NULL;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user