Skip to content

Commit 126bc44

Browse files
akxhomm
andcommitted
Fix up most noqas
Update Tests/bench_cffi_access.py Co-authored-by: Alexander Karpinsky <[email protected]>
1 parent 556dd1e commit 126bc44

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Tests/bench_cffi_access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_direct():
4545

4646
assert caccess[(0, 0)] == access[(0, 0)]
4747

48-
print("Size: %sx%s" % im.size) # noqa: UP031
48+
print(f"Size: {im.width}x{im.height}")
4949
timer(iterate_get, "PyAccess - get", im.size, access)
5050
timer(iterate_set, "PyAccess - set", im.size, access)
5151
timer(iterate_get, "C-api - get", im.size, caccess)

src/PIL/EpsImagePlugin.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
7777

7878
# Hack to support hi-res rendering
7979
scale = int(scale) or 1
80-
size = (size[0] * scale, size[1] * scale)
80+
width = size[0] * scale
81+
height = size[1] * scale
8182
# resolution is dependent on bbox and size
82-
res = (
83-
72.0 * size[0] / (bbox[2] - bbox[0]),
84-
72.0 * size[1] / (bbox[3] - bbox[1]),
85-
)
83+
res_x = 72.0 * width / (bbox[2] - bbox[0])
84+
res_y = 72.0 * height / (bbox[3] - bbox[1])
8685

8786
out_fd, outfile = tempfile.mkstemp()
8887
os.close(out_fd)
@@ -119,8 +118,8 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
119118
command = [
120119
gs_binary,
121120
"-q", # quiet mode
122-
"-g%dx%d" % size, # set output geometry (pixels)
123-
"-r%fx%f" % res, # set input DPI (dots per inch) # noqa: UP031
121+
f"-g{width:d}x{height:d}", # set output geometry (pixels)
122+
f"-r{res_x:f}x{res_y:f}", # set input DPI (dots per inch)
124123
"-dBATCH", # exit after processing
125124
"-dNOPAUSE", # don't pause between pages
126125
"-dSAFER", # safe mode

src/PIL/IcnsImagePlugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ def _accept(prefix):
391391
with open(sys.argv[1], "rb") as fp:
392392
imf = IcnsImageFile(fp)
393393
for size in imf.info["sizes"]:
394-
imf.size = size
395-
imf.save("out-%s-%s-%s.png" % size) # noqa: UP031
394+
w, h, x = imf.size = size
395+
imf.save(f"out-{w}-{h}-{x}.png")
396396
with Image.open(sys.argv[1]) as im:
397397
im.save("out.png")
398398
if sys.platform == "windows":

src/PIL/Image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3100,7 +3100,8 @@ def fromarray(obj, mode=None):
31003100
try:
31013101
mode, rawmode = _fromarray_typemap[typekey]
31023102
except KeyError as e:
3103-
msg = "Cannot handle this data type: %s, %s" % typekey # noqa: UP031
3103+
typ_shape, typ_type = typekey
3104+
msg = f"Cannot handle this data type: {typ_shape}, {typ_type}"
31043105
raise TypeError(msg) from e
31053106
else:
31063107
rawmode = mode

src/PIL/PdfParser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class IndirectReference(
8282
collections.namedtuple("IndirectReferenceTuple", ["object_id", "generation"])
8383
):
8484
def __str__(self):
85-
return "%s %s R" % self # noqa: UP031
85+
return f"{self.object_id} {self.generation} R"
8686

8787
def __bytes__(self):
8888
return self.__str__().encode("us-ascii")
@@ -103,7 +103,7 @@ def __hash__(self):
103103

104104
class IndirectObjectDef(IndirectReference):
105105
def __str__(self):
106-
return "%s %s obj" % self # noqa: UP031
106+
return f"{self.object_id} {self.generation} obj"
107107

108108

109109
class XrefTable:

0 commit comments

Comments
 (0)