Skip to content

Commit

Permalink
language tidyups for python 3.7+
Browse files Browse the repository at this point in the history
 - removed unnecessary f-string
 - removed inherit of object
 - converted some format strings to fstrings
 - simplied some loops to just create lists

Signed-off-by: Mark Mayo <mark@there.co.nz>
  • Loading branch information
marksmayo committed Apr 17, 2023
1 parent fe138e5 commit 222982f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/gen_api_nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def main():
full_doc_path = full_doc_path.as_posix().replace("\\", "/")
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
print(f"::: " + ident, file=fd)
print("::: " + ident, file=fd)

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

Expand Down
2 changes: 1 addition & 1 deletion docs/gen_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
)


class Examples(object):
class Examples():
def __init__(self, root: Path):
self._root = root

Expand Down
2 changes: 1 addition & 1 deletion photoshop/api/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from photoshop.api.errors import PhotoshopPythonAPIError


class Photoshop(object):
class Photoshop():
"""Core API for all photoshop objects."""

_root = "Photoshop"
Expand Down
4 changes: 2 additions & 2 deletions photoshop/api/_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def fullName(self):
return Path(self.app.fullName)
except COMError:
self.eval_javascript(
'alert ("Please save your Document first!",' '"{}")'.format(self.name),
f'alert ("Please save your Document first!","{self.name}")',
)

@property
Expand Down Expand Up @@ -237,7 +237,7 @@ def path(self) -> str:
return Path(self.app.path)
except COMError:
self.eval_javascript(
'alert ("Please save your Document first!",' '"{}")'.format(self.name),
f'alert ("Please save your Document first!","{self.name}")',
)

@path.setter
Expand Down
2 changes: 1 addition & 1 deletion photoshop/api/_notifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, parent: Optional[Any] = None):

@property
def _notifiers(self) -> list:
return [n for n in self.app]
return list(self.app)

def __len__(self):
return self.length
Expand Down
2 changes: 1 addition & 1 deletion photoshop/api/_text_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __iter__(self):

@property
def _fonts(self):
return [a for a in self.app]
return list(self.app)

def __len__(self):
return self.length
Expand Down
16 changes: 3 additions & 13 deletions photoshop/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ def doAction(self, action, action_from="Default Actions"):
return True

def doForcedProgress(self, title, javascript):
script = "app.doForcedProgress('{}', '{}')".format(
title,
javascript,
)
script = f"app.doForcedProgress('{title}', '{javascript}')"
self.eval_javascript(script)
# Ensure the script execute success.
time.sleep(1)
Expand All @@ -307,10 +304,7 @@ def doProgress(self, title, javascript):
javascript (str): JavaScriptString to execute.
"""
script = "app.doProgress('{}', '{}')".format(
title,
javascript,
)
script = f"app.doProgress('{title}', '{javascript}')"
self.eval_javascript(script)
# Ensure the script execute success.
time.sleep(1)
Expand All @@ -327,11 +321,7 @@ def doProgressSegmentTask(self, segmentLength, done, total, javascript):
time.sleep(1)

def doProgressSubTask(self, index, limit, javascript):
script = "app.doProgressSubTask({}, {}, '{}');".format(
index,
limit,
javascript,
)
script = f"app.doProgressSubTask({index}, {limit}, '{javascript}');"
self.eval_javascript(script)
# Ensure the script execute success.
time.sleep(1)
Expand Down
2 changes: 1 addition & 1 deletion test/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def test_imports():
"""Test import modules."""
prefix = "{}.".format(photoshop.__name__)
prefix = f"{photoshop.__name__}."
iter_packages = pkgutil.walk_packages(
photoshop.__path__, # noqa: WPS609
prefix,
Expand Down

0 comments on commit 222982f

Please sign in to comment.