Skip to content

Commit f3c83cf

Browse files
hugovkBoboTiG
authored andcommitted
Upgrade Python syntax with pyupgrade https://github.com/asottile/pyupgrade
1 parent 9f88017 commit f3c83cf

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

docs/source/examples/callback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def on_exists(fname):
2020

2121
if os.path.isfile(fname):
2222
newfile = fname + ".old"
23-
print("{0} -> {1}".format(fname, newfile))
23+
print("{} -> {}".format(fname, newfile))
2424
os.rename(fname, newfile)
2525

2626

docs/source/examples/opencv_numpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# cv2.imshow('OpenCV/Numpy grayscale',
3131
# cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))
3232

33-
print("fps: {0}".format(1 / (time.time() - last_time)))
33+
print("fps: {}".format(1 / (time.time() - last_time)))
3434

3535
# Press "q" to quit
3636
if cv2.waitKey(25) & 0xFF == ord("q"):

docs/source/examples/pil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
# img = Image.frombytes('RGB', sct_img.size, sct_img.rgb)
2323

2424
# And save it!
25-
output = "monitor-{0}.png".format(num)
25+
output = "monitor-{}.png".format(num)
2626
img.save(output)
2727
print(output)

mss/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def save(self, mon=0, output="monitor-{mon}.png", callback=None):
116116
try:
117117
monitor = monitors[mon]
118118
except IndexError:
119-
raise ScreenShotError("Monitor {0!r} does not exist.".format(mon))
119+
raise ScreenShotError("Monitor {!r} does not exist.".format(mon))
120120

121121
output = output.format(mon=mon, date=datetime.now(), **monitor)
122122
if callable(callback):

mss/darwin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CGPoint(ctypes.Structure):
3232
_fields_ = [("x", cgfloat()), ("y", cgfloat())]
3333

3434
def __repr__(self):
35-
return "{0}(left={1} top={2})".format(type(self).__name__, self.x, self.y)
35+
return "{}(left={} top={})".format(type(self).__name__, self.x, self.y)
3636

3737

3838
class CGSize(ctypes.Structure):
@@ -41,7 +41,7 @@ class CGSize(ctypes.Structure):
4141
_fields_ = [("width", cgfloat()), ("height", cgfloat())]
4242

4343
def __repr__(self):
44-
return "{0}(width={1} height={2})".format(
44+
return "{}(width={} height={})".format(
4545
type(self).__name__, self.width, self.height
4646
)
4747

@@ -52,7 +52,7 @@ class CGRect(ctypes.Structure):
5252
_fields_ = [("origin", CGPoint), ("size", CGSize)]
5353

5454
def __repr__(self):
55-
return "{0}<{1} {2}>".format(type(self).__name__, self.origin, self.size)
55+
return "{}<{} {}>".format(type(self).__name__, self.origin, self.size)
5656

5757

5858
class MSS(MSSBase):

mss/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def mss(**kwargs):
3030
from .windows import MSS
3131
else:
3232
raise ScreenShotError(
33-
"System {0!r} not (yet?) implemented.".format(operating_system)
33+
"System {!r} not (yet?) implemented.".format(operating_system)
3434
)
3535

3636
return MSS(**kwargs)

mss/linux.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def __init__(self, display=None):
170170
display = display.encode("utf-8")
171171

172172
if b":" not in display:
173-
raise ScreenShotError("Bad display value: {0!r}.".format(display))
173+
raise ScreenShotError("Bad display value: {!r}.".format(display))
174174

175175
x11 = ctypes.util.find_library("X11")
176176
if not x11:
@@ -313,7 +313,7 @@ def validate(retval, func, args):
313313
if retval != 0 and not MSS.last_error:
314314
return args
315315

316-
err = "{0}() failed".format(func.__name__)
316+
err = "{}() failed".format(func.__name__)
317317
details = {"retval": retval, "args": args}
318318

319319
if MSS.last_error:
@@ -329,7 +329,7 @@ def validate(retval, func, args):
329329
xerror = xserver_error.value.decode("utf-8")
330330
if xerror != "0":
331331
details["xerror"] = xerror
332-
err += ": {0}".format(xerror)
332+
err += ": {}".format(xerror)
333333

334334
raise ScreenShotError(err, details=details)
335335

@@ -407,7 +407,7 @@ def grab(self, monitor):
407407
bits_per_pixel = ximage.contents.bits_per_pixel
408408
if bits_per_pixel != 32:
409409
raise ScreenShotError(
410-
"[XImage] bits per pixel value not (yet?) implemented: {0}.".format(
410+
"[XImage] bits per pixel value not (yet?) implemented: {}.".format(
411411
bits_per_pixel
412412
)
413413
)

mss/screenshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,5 @@ def pixel(self, coord_x, coord_y):
149149
return self.pixels[coord_y][coord_x]
150150
except IndexError:
151151
raise ScreenShotError(
152-
"Pixel location ({0}, {1}) is out of range.".format(coord_x, coord_y)
152+
"Pixel location ({}, {}) is out of range.".format(coord_x, coord_y)
153153
)

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def purge_files():
1919
""" Remove all generated files from previous runs. """
2020

2121
for fname in glob.glob("*.png"):
22-
print("Deleting {0!r} ...".format(fname))
22+
print("Deleting {!r} ...".format(fname))
2323
os.unlink(fname)
2424

2525
for fname in glob.glob("*.png.old"):
26-
print("Deleting {0!r} ...".format(fname))
26+
print("Deleting {!r} ...".format(fname))
2727
os.unlink(fname)
2828

2929

0 commit comments

Comments
 (0)