Skip to content

Commit

Permalink
Fix up most noqas
Browse files Browse the repository at this point in the history
Update Tests/bench_cffi_access.py

Co-authored-by: Alexander Karpinsky <[email protected]>
  • Loading branch information
akx and homm committed Nov 12, 2023
1 parent 556dd1e commit 126bc44
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Tests/bench_cffi_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_direct():

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

print("Size: %sx%s" % im.size) # noqa: UP031
print(f"Size: {im.width}x{im.height}")
timer(iterate_get, "PyAccess - get", im.size, access)
timer(iterate_set, "PyAccess - set", im.size, access)
timer(iterate_get, "C-api - get", im.size, caccess)
Expand Down
13 changes: 6 additions & 7 deletions src/PIL/EpsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):

# Hack to support hi-res rendering
scale = int(scale) or 1
size = (size[0] * scale, size[1] * scale)
width = size[0] * scale
height = size[1] * scale
# resolution is dependent on bbox and size
res = (
72.0 * size[0] / (bbox[2] - bbox[0]),
72.0 * size[1] / (bbox[3] - bbox[1]),
)
res_x = 72.0 * width / (bbox[2] - bbox[0])
res_y = 72.0 * height / (bbox[3] - bbox[1])

out_fd, outfile = tempfile.mkstemp()
os.close(out_fd)
Expand Down Expand Up @@ -119,8 +118,8 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
command = [
gs_binary,
"-q", # quiet mode
"-g%dx%d" % size, # set output geometry (pixels)
"-r%fx%f" % res, # set input DPI (dots per inch) # noqa: UP031
f"-g{width:d}x{height:d}", # set output geometry (pixels)
f"-r{res_x:f}x{res_y:f}", # set input DPI (dots per inch)
"-dBATCH", # exit after processing
"-dNOPAUSE", # don't pause between pages
"-dSAFER", # safe mode
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/IcnsImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ def _accept(prefix):
with open(sys.argv[1], "rb") as fp:
imf = IcnsImageFile(fp)
for size in imf.info["sizes"]:
imf.size = size
imf.save("out-%s-%s-%s.png" % size) # noqa: UP031
w, h, x = imf.size = size
imf.save(f"out-{w}-{h}-{x}.png")
with Image.open(sys.argv[1]) as im:
im.save("out.png")
if sys.platform == "windows":
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3100,7 +3100,8 @@ def fromarray(obj, mode=None):
try:
mode, rawmode = _fromarray_typemap[typekey]
except KeyError as e:
msg = "Cannot handle this data type: %s, %s" % typekey # noqa: UP031
typ_shape, typ_type = typekey
msg = f"Cannot handle this data type: {typ_shape}, {typ_type}"

Check warning on line 3104 in src/PIL/Image.py

View check run for this annotation

Codecov / codecov/patch

src/PIL/Image.py#L3103-L3104

Added lines #L3103 - L3104 were not covered by tests
raise TypeError(msg) from e
else:
rawmode = mode
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/PdfParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class IndirectReference(
collections.namedtuple("IndirectReferenceTuple", ["object_id", "generation"])
):
def __str__(self):
return "%s %s R" % self # noqa: UP031
return f"{self.object_id} {self.generation} R"

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

class IndirectObjectDef(IndirectReference):
def __str__(self):
return "%s %s obj" % self # noqa: UP031
return f"{self.object_id} {self.generation} obj"


class XrefTable:
Expand Down

0 comments on commit 126bc44

Please sign in to comment.