Skip to content

Commit 1719eb2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b8ec8aa commit 1719eb2

22 files changed

+170
-144
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
import sys
1717
import warnings
1818
from collections.abc import Iterator
19-
from typing import Any, TYPE_CHECKING
19+
from typing import TYPE_CHECKING, Any
2020

2121
from setuptools import Extension, setup
2222
from setuptools.command.build_ext import build_ext
23+
2324
if TYPE_CHECKING:
2425
from setuptools import _BuildInfo
2526

src/Tk/tkImaging.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ PyImagingPhotoPut(
124124
if (im->mode == IMAGING_MODE_1 || im->mode == IMAGING_MODE_L) {
125125
block.pixelSize = 1;
126126
block.offset[0] = block.offset[1] = block.offset[2] = block.offset[3] = 0;
127-
} else if (
128-
im->mode == IMAGING_MODE_RGB || im->mode == IMAGING_MODE_RGBA ||
129-
im->mode == IMAGING_MODE_RGBX || im->mode == IMAGING_MODE_RGBa
130-
) {
127+
} else if (im->mode == IMAGING_MODE_RGB || im->mode == IMAGING_MODE_RGBA ||
128+
im->mode == IMAGING_MODE_RGBX || im->mode == IMAGING_MODE_RGBa) {
131129
block.pixelSize = 4;
132130
block.offset[0] = 0;
133131
block.offset[1] = 1;

src/_imaging.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,9 @@ _quantize(ImagingObject *self, PyObject *args) {
17201720

17211721
if (!self->image->xsize || !self->image->ysize) {
17221722
/* no content; return an empty image */
1723-
return PyImagingNew(ImagingNew(IMAGING_MODE_P, self->image->xsize, self->image->ysize));
1723+
return PyImagingNew(
1724+
ImagingNew(IMAGING_MODE_P, self->image->xsize, self->image->ysize)
1725+
);
17241726
}
17251727

17261728
return PyImagingNew(ImagingQuantize(self->image, colours, method, kmeans));
@@ -2004,7 +2006,8 @@ _reduce(ImagingObject *self, PyObject *args) {
20042006

20052007
static int
20062008
isRGB(const ModeID mode) {
2007-
return mode == IMAGING_MODE_RGB || mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_RGBX;
2009+
return mode == IMAGING_MODE_RGB || mode == IMAGING_MODE_RGBA ||
2010+
mode == IMAGING_MODE_RGBX;
20082011
}
20092012

20102013
static PyObject *

src/_imagingcms.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ cms_transform_dealloc(CmsTransformObject *self) {
212212
/* internal functions */
213213

214214
static cmsUInt32Number
215-
findLCMStype(const char * const mode_name) {
215+
findLCMStype(const char *const mode_name) {
216216
const ModeID mode = findModeID(mode_name);
217217
switch (mode) {
218218
case IMAGING_MODE_RGB:
@@ -230,7 +230,9 @@ findLCMStype(const char * const mode_name) {
230230
return TYPE_YCbCr_8;
231231
case IMAGING_MODE_LAB:
232232
// LabX equivalent like ALab, but not reversed -- no #define in lcms2
233-
return (COLORSPACE_SH(PT_LabV2) | CHANNELS_SH(3) | BYTES_SH(1) | EXTRA_SH(1));
233+
return (
234+
COLORSPACE_SH(PT_LabV2) | CHANNELS_SH(3) | BYTES_SH(1) | EXTRA_SH(1)
235+
);
234236
default:
235237
// This function only accepts a subset of the imaging modes Pillow has.
236238
break;

src/_imagingft.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,14 @@ font_getsize(FontObject *self, PyObject *args) {
769769
/* calculate size and bearing for a given string */
770770

771771
if (!PyArg_ParseTuple(
772-
args, "O|zzOzz:getsize", &string, &mode_name, &dir, &features, &lang, &anchor
772+
args,
773+
"O|zzOzz:getsize",
774+
&string,
775+
&mode_name,
776+
&dir,
777+
&features,
778+
&lang,
779+
&anchor
773780
)) {
774781
return NULL;
775782
}

src/decode.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ static PyTypeObject ImagingDecoderType = {
293293
/* -------------------------------------------------------------------- */
294294

295295
int
296-
get_unpacker(ImagingDecoderObject *decoder, const ModeID mode, const RawModeID rawmode) {
296+
get_unpacker(
297+
ImagingDecoderObject *decoder, const ModeID mode, const RawModeID rawmode
298+
) {
297299
int bits;
298300
ImagingShuffler unpack;
299301

@@ -324,7 +326,9 @@ PyImaging_BitDecoderNew(PyObject *self, PyObject *args) {
324326
int fill = 0;
325327
int sign = 0;
326328
int ystep = 1;
327-
if (!PyArg_ParseTuple(args, "s|iiiii", &mode_name, &bits, &pad, &fill, &sign, &ystep)) {
329+
if (!PyArg_ParseTuple(
330+
args, "s|iiiii", &mode_name, &bits, &pad, &fill, &sign, &ystep
331+
)) {
328332
return NULL;
329333
}
330334

@@ -435,7 +439,9 @@ PyImaging_GifDecoderNew(PyObject *self, PyObject *args) {
435439
int bits = 8;
436440
int interlace = 0;
437441
int transparency = -1;
438-
if (!PyArg_ParseTuple(args, "s|iii", &mode_name, &bits, &interlace, &transparency)) {
442+
if (!PyArg_ParseTuple(
443+
args, "s|iii", &mode_name, &bits, &interlace, &transparency
444+
)) {
439445
return NULL;
440446
}
441447

@@ -508,7 +514,9 @@ PyImaging_LibTiffDecoderNew(PyObject *self, PyObject *args) {
508514
int fp;
509515
uint32_t ifdoffset;
510516

511-
if (!PyArg_ParseTuple(args, "sssiI", &mode_name, &rawmode_name, &compname, &fp, &ifdoffset)) {
517+
if (!PyArg_ParseTuple(
518+
args, "sssiI", &mode_name, &rawmode_name, &compname, &fp, &ifdoffset
519+
)) {
512520
return NULL;
513521
}
514522

@@ -850,12 +858,14 @@ PyImaging_JpegDecoderNew(PyObject *self, PyObject *args) {
850858
ImagingDecoderObject *decoder;
851859

852860
char *mode_name;
853-
char *rawmode_name; /* what we want from the decoder */
861+
char *rawmode_name; /* what we want from the decoder */
854862
char *jpegmode_name; /* what's in the file */
855863
int scale = 1;
856864
int draft = 0;
857865

858-
if (!PyArg_ParseTuple(args, "ssz|ii", &mode_name, &rawmode_name, &jpegmode_name, &scale, &draft)) {
866+
if (!PyArg_ParseTuple(
867+
args, "ssz|ii", &mode_name, &rawmode_name, &jpegmode_name, &scale, &draft
868+
)) {
859869
return NULL;
860870
}
861871

src/encode.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,12 @@ get_packer(ImagingEncoderObject *encoder, const ModeID mode, const RawModeID raw
367367
pack = ImagingFindPacker(mode, rawmode, &bits);
368368
if (!pack) {
369369
Py_DECREF(encoder);
370-
PyErr_Format(PyExc_ValueError, "No packer found from %s to %s", getModeData(mode)->name, getRawModeData(rawmode)->name);
370+
PyErr_Format(
371+
PyExc_ValueError,
372+
"No packer found from %s to %s",
373+
getModeData(mode)->name,
374+
getRawModeData(rawmode)->name
375+
);
371376
return -1;
372377
}
373378

@@ -407,7 +412,9 @@ PyImaging_GifEncoderNew(PyObject *self, PyObject *args) {
407412
char *rawmode_name;
408413
Py_ssize_t bits = 8;
409414
Py_ssize_t interlace = 0;
410-
if (!PyArg_ParseTuple(args, "ss|nn", &mode_name, &rawmode_name, &bits, &interlace)) {
415+
if (!PyArg_ParseTuple(
416+
args, "ss|nn", &mode_name, &rawmode_name, &bits, &interlace
417+
)) {
411418
return NULL;
412419
}
413420

@@ -1152,7 +1159,7 @@ PyImaging_JpegEncoderNew(PyObject *self, PyObject *args) {
11521159
}
11531160

11541161
const ModeID mode = findModeID(mode_name);
1155-
RawModeID rawmode = findRawModeID(rawmode_name);
1162+
RawModeID rawmode = findRawModeID(rawmode_name);
11561163

11571164
// libjpeg-turbo supports different output formats.
11581165
// We are choosing Pillow's native format (3 color bytes + 1 padding)

src/libImaging/Access.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
#include "Imaging.h"
1313

14-
1514
/* fetch individual pixel */
1615

1716
static void
@@ -102,7 +101,6 @@ get_pixel_32B(Imaging im, int x, int y, void *color) {
102101
#endif
103102
}
104103

105-
106104
/* store individual pixel */
107105

108106
static void
@@ -153,7 +151,6 @@ put_pixel_32(Imaging im, int x, int y, const void *color) {
153151
memcpy(&im->image32[y][x], color, sizeof(INT32));
154152
}
155153

156-
157154
static struct ImagingAccessInstance accessors[] = {
158155
{IMAGING_MODE_1, get_pixel_8, put_pixel_8},
159156
{IMAGING_MODE_L, get_pixel_8, put_pixel_8},

src/libImaging/Chops.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@
4242
} \
4343
return imOut;
4444

45-
#define CHOP2(operation, mode) \
46-
int x, y; \
47-
Imaging imOut; \
48-
imOut = create(imIn1, imIn2, mode); \
49-
if (!imOut) { \
50-
return NULL; \
51-
} \
52-
for (y = 0; y < imOut->ysize; y++) { \
53-
UINT8 *out = (UINT8 *)imOut->image[y]; \
54-
UINT8 *in1 = (UINT8 *)imIn1->image[y]; \
55-
UINT8 *in2 = (UINT8 *)imIn2->image[y]; \
56-
for (x = 0; x < imOut->linesize; x++) { \
57-
out[x] = operation; \
58-
} \
59-
} \
45+
#define CHOP2(operation, mode) \
46+
int x, y; \
47+
Imaging imOut; \
48+
imOut = create(imIn1, imIn2, mode); \
49+
if (!imOut) { \
50+
return NULL; \
51+
} \
52+
for (y = 0; y < imOut->ysize; y++) { \
53+
UINT8 *out = (UINT8 *)imOut->image[y]; \
54+
UINT8 *in1 = (UINT8 *)imIn1->image[y]; \
55+
UINT8 *in2 = (UINT8 *)imIn2->image[y]; \
56+
for (x = 0; x < imOut->linesize; x++) { \
57+
out[x] = operation; \
58+
} \
59+
} \
6060
return imOut;
6161

6262
static Imaging

src/libImaging/Convert.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,9 +1624,7 @@ static struct {
16241624
};
16251625

16261626
static Imaging
1627-
convert(
1628-
Imaging imOut, Imaging imIn, ModeID mode, ImagingPalette palette, int dither
1629-
) {
1627+
convert(Imaging imOut, Imaging imIn, ModeID mode, ImagingPalette palette, int dither) {
16301628
ImagingSectionCookie cookie;
16311629
ImagingShuffler convert;
16321630

@@ -1677,7 +1675,11 @@ convert(
16771675
#else
16781676
static char buf[100];
16791677
snprintf(
1680-
buf, 100, "conversion from %.10s to %.10s not supported", getModeData(imIn->mode)->name, getModeData(mode)->name
1678+
buf,
1679+
100,
1680+
"conversion from %.10s to %.10s not supported",
1681+
getModeData(imIn->mode)->name,
1682+
getModeData(mode)->name
16811683
);
16821684
return (Imaging)ImagingError_ValueError(buf);
16831685
#endif
@@ -1722,25 +1724,22 @@ ImagingConvertTransparent(Imaging imIn, const ModeID mode, int r, int g, int b)
17221724
return (Imaging)ImagingError_ModeError();
17231725
}
17241726

1725-
if (imIn->mode == IMAGING_MODE_RGB && (mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_RGBa)) {
1727+
if (imIn->mode == IMAGING_MODE_RGB &&
1728+
(mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_RGBa)) {
17261729
convert = rgb2rgba;
17271730
if (mode == IMAGING_MODE_RGBa) {
17281731
premultiplied = 1;
17291732
}
1730-
} else if (imIn->mode == IMAGING_MODE_RGB && (mode == IMAGING_MODE_LA || mode == IMAGING_MODE_La)) {
1733+
} else if (imIn->mode == IMAGING_MODE_RGB &&
1734+
(mode == IMAGING_MODE_LA || mode == IMAGING_MODE_La)) {
17311735
convert = rgb2la;
17321736
source_transparency = 1;
17331737
if (mode == IMAGING_MODE_La) {
17341738
premultiplied = 1;
17351739
}
1736-
} else if ((imIn->mode == IMAGING_MODE_1 ||
1737-
imIn->mode == IMAGING_MODE_I ||
1738-
imIn->mode == IMAGING_MODE_I_16 ||
1739-
imIn->mode == IMAGING_MODE_L
1740-
) && (
1741-
mode == IMAGING_MODE_RGBA ||
1742-
mode == IMAGING_MODE_LA
1743-
)) {
1740+
} else if ((imIn->mode == IMAGING_MODE_1 || imIn->mode == IMAGING_MODE_I ||
1741+
imIn->mode == IMAGING_MODE_I_16 || imIn->mode == IMAGING_MODE_L) &&
1742+
(mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_LA)) {
17441743
if (imIn->mode == IMAGING_MODE_1) {
17451744
convert = bit2rgb;
17461745
} else if (imIn->mode == IMAGING_MODE_I) {

0 commit comments

Comments
 (0)