Skip to content

Commit a4b2bfc

Browse files
committed
language tidyups for python 3.7+
- removed unnecessary f-string - removed inherit of object - converted some format strings to fstrings - simplied some loops to just create lists
1 parent fe138e5 commit a4b2bfc

File tree

8 files changed

+11
-21
lines changed

8 files changed

+11
-21
lines changed

docs/gen_api_nav.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def main():
2929
full_doc_path = full_doc_path.as_posix().replace("\\", "/")
3030
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
3131
ident = ".".join(parts)
32-
print(f"::: " + ident, file=fd)
32+
print("::: " + ident, file=fd)
3333

3434
mkdocs_gen_files.set_edit_path(full_doc_path, path.as_posix().replace("\\", "/"))
3535

docs/gen_examples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
)
2727

2828

29-
class Examples(object):
29+
class Examples():
3030
def __init__(self, root: Path):
3131
self._root = root
3232

photoshop/api/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from photoshop.api.errors import PhotoshopPythonAPIError
1616

1717

18-
class Photoshop(object):
18+
class Photoshop():
1919
"""Core API for all photoshop objects."""
2020

2121
_root = "Photoshop"

photoshop/api/_document.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def fullName(self):
161161
return Path(self.app.fullName)
162162
except COMError:
163163
self.eval_javascript(
164-
'alert ("Please save your Document first!",' '"{}")'.format(self.name),
164+
f'alert ("Please save your Document first!","{self.name}")',
165165
)
166166

167167
@property
@@ -237,7 +237,7 @@ def path(self) -> str:
237237
return Path(self.app.path)
238238
except COMError:
239239
self.eval_javascript(
240-
'alert ("Please save your Document first!",' '"{}")'.format(self.name),
240+
f'alert ("Please save your Document first!","{self.name}")',
241241
)
242242

243243
@path.setter

photoshop/api/_notifiers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, parent: Optional[Any] = None):
2727

2828
@property
2929
def _notifiers(self) -> list:
30-
return [n for n in self.app]
30+
return list(self.app)
3131

3232
def __len__(self):
3333
return self.length

photoshop/api/_text_fonts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __iter__(self):
1616

1717
@property
1818
def _fonts(self):
19-
return [a for a in self.app]
19+
return list(self.app)
2020

2121
def __len__(self):
2222
return self.length

photoshop/api/application.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,7 @@ def doAction(self, action, action_from="Default Actions"):
290290
return True
291291

292292
def doForcedProgress(self, title, javascript):
293-
script = "app.doForcedProgress('{}', '{}')".format(
294-
title,
295-
javascript,
296-
)
293+
script = f"app.doForcedProgress('{title}', '{javascript}')"
297294
self.eval_javascript(script)
298295
# Ensure the script execute success.
299296
time.sleep(1)
@@ -307,10 +304,7 @@ def doProgress(self, title, javascript):
307304
javascript (str): JavaScriptString to execute.
308305
309306
"""
310-
script = "app.doProgress('{}', '{}')".format(
311-
title,
312-
javascript,
313-
)
307+
script = f"app.doProgress('{title}', '{javascript}')"
314308
self.eval_javascript(script)
315309
# Ensure the script execute success.
316310
time.sleep(1)
@@ -327,11 +321,7 @@ def doProgressSegmentTask(self, segmentLength, done, total, javascript):
327321
time.sleep(1)
328322

329323
def doProgressSubTask(self, index, limit, javascript):
330-
script = "app.doProgressSubTask({}, {}, '{}');".format(
331-
index,
332-
limit,
333-
javascript,
334-
)
324+
script = f"app.doProgressSubTask({index}, {limit}, '{javascript}');"
335325
self.eval_javascript(script)
336326
# Ensure the script execute success.
337327
time.sleep(1)

test/test_imports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_imports():
1717
"""Test import modules."""
18-
prefix = "{}.".format(photoshop.__name__)
18+
prefix = f"{photoshop.__name__}."
1919
iter_packages = pkgutil.walk_packages(
2020
photoshop.__path__, # noqa: WPS609
2121
prefix,

0 commit comments

Comments
 (0)