Skip to content

Commit 7122a4e

Browse files
committed
Format with Black
1 parent 3983d43 commit 7122a4e

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/PIL/ImageFont.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,23 @@ def __init__(self, font=None, size=10, index=0, encoding="", layout_engine=None)
143143
def load_from_bytes(f):
144144
self.font_bytes = f.read()
145145
self.font = core.getfont(
146-
"", size, index, encoding, self.font_bytes, layout_engine)
146+
"", size, index, encoding, self.font_bytes, layout_engine
147+
)
147148

148149
if isPath(font):
149150
if sys.platform == "win32":
150151
font_bytes_path = font if isinstance(font, bytes) else font.encode()
151152
try:
152-
font_bytes_path.decode('ascii')
153+
font_bytes_path.decode("ascii")
153154
except UnicodeDecodeError:
154155
# FreeType cannot load fonts with non-ASCII characters on Windows
155156
# So load it into memory first
156-
with open(font, 'rb') as f:
157+
with open(font, "rb") as f:
157158
load_from_bytes(f)
158159
return
159-
self.font = core.getfont(font, size, index, encoding,
160-
layout_engine=layout_engine)
160+
self.font = core.getfont(
161+
font, size, index, encoding, layout_engine=layout_engine
162+
)
161163
else:
162164
load_from_bytes(font)
163165

@@ -483,8 +485,10 @@ def truetype(font=None, size=10, index=0, encoding="", layout_engine=None):
483485
:return: A font object.
484486
:exception IOError: If the file could not be read.
485487
"""
488+
486489
def freetype(font):
487490
return FreeTypeFont(font, size, index, encoding, layout_engine)
491+
488492
try:
489493
return freetype(font)
490494
except IOError:
@@ -519,13 +523,11 @@ def freetype(font):
519523
for walkfilename in walkfilenames:
520524
if ext and walkfilename == ttf_filename:
521525
return freetype(os.path.join(walkroot, walkfilename))
522-
elif (not ext and
523-
os.path.splitext(walkfilename)[0] == ttf_filename):
526+
elif not ext and os.path.splitext(walkfilename)[0] == ttf_filename:
524527
fontpath = os.path.join(walkroot, walkfilename)
525-
if os.path.splitext(fontpath)[1] == '.ttf':
528+
if os.path.splitext(fontpath)[1] == ".ttf":
526529
return freetype(fontpath)
527-
if not ext \
528-
and first_font_with_a_different_extension is None:
530+
if not ext and first_font_with_a_different_extension is None:
529531
first_font_with_a_different_extension = fontpath
530532
if first_font_with_a_different_extension:
531533
return freetype(first_font_with_a_different_extension)

src/PIL/ImageGrab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from . import Image
1919

2020
import sys
21+
2122
if sys.platform == "win32":
2223
grabber = Image.core.grabscreen
2324
elif sys.platform == "darwin":

src/PIL/PalmImagePlugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,14 @@ def _save(im, fp, filename):
132132
# Palm does greyscale from white (0) to black (1)
133133
bpp = im.encoderinfo["bpp"]
134134
im = im.point(
135-
lambda x, shift=8-bpp, maxval=(1 << bpp)-1: maxval - (x >> shift))
135+
lambda x, shift=8 - bpp, maxval=(1 << bpp) - 1: maxval - (x >> shift)
136+
)
136137
elif im.info.get("bpp") in (1, 2, 4):
137138
# here we assume that even though the inherent mode is 8-bit grayscale,
138139
# only the lower bpp bits are significant.
139140
# We invert them to match the Palm.
140141
bpp = im.info["bpp"]
141-
im = im.point(lambda x, maxval=(1 << bpp)-1: maxval - (x & maxval))
142+
im = im.point(lambda x, maxval=(1 << bpp) - 1: maxval - (x & maxval))
142143
else:
143144
raise IOError("cannot write mode %s as Palm" % im.mode)
144145

src/PIL/TiffImagePlugin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@
251251
(MM, 5, (1,), 1, (8, 8, 8, 8, 8), (0,)): ("CMYK", "CMYKX"),
252252
(II, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0)): ("CMYK", "CMYKXX"),
253253
(MM, 5, (1,), 1, (8, 8, 8, 8, 8, 8), (0, 0)): ("CMYK", "CMYKXX"),
254-
255254
(II, 5, (1,), 1, (16, 16, 16, 16), ()): ("CMYK", "CMYK;16L"),
256-
257255
# JPEG compressed images handled by LibTiff and auto-converted to RGBX
258256
# Minimal Baseline TIFF requires YCbCr images to have 3 SamplesPerPixel
259257
(II, 6, (1,), 1, (8, 8, 8), ()): ("RGB", "RGBX"),

0 commit comments

Comments
 (0)