Skip to content

Commit fe848d5

Browse files
committed
style(action_manager): extinguish flake8 error
1 parent 4461d91 commit fe848d5

19 files changed

+64
-40
lines changed

photoshop/api/action_manager/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
from .desc_value_types import *
2-
from .jprint import *
1+
from .desc_value_types import Enumerated
2+
from .desc_value_types import TypeID
3+
from .desc_value_types import UnitDouble
4+
from .jprint import jformat
5+
from .jprint import jprint
36
from .js_converter import dump as dumpjs
4-
from .ref_form_types import *
5-
from .utils import *
7+
from .ref_form_types import Identifier
8+
from .ref_form_types import Index
9+
from .ref_form_types import Offset
10+
from .ref_form_types import ReferenceKey
11+
from .utils import id2str
12+
from .utils import str2id
613

714

815
__all__ = [ # noqa: F405

photoshop/api/action_manager/_main_types/_type_mapper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
Handles almost all type mappings. (Some else are in ReferenceKey.)
33
This module is INTERNAL. You should not import functions from it."""
44

5-
from ..desc_value_types import *
6-
from ..ref_form_types import *
7-
from ..utils import *
5+
from ..desc_value_types import Enumerated
6+
from ..desc_value_types import TypeID
7+
from ..desc_value_types import UnitDouble
8+
from ..utils import id2str
89

910

1011
__all__ = ["unpack", "pack", "parsetype"]
@@ -34,7 +35,7 @@ def unpack(val):
3435
typestr = pytype2str[vtype]
3536
try:
3637
args = val._unpacker()
37-
except:
38+
except BaseException:
3839
args = (val,)
3940
return (typestr, args)
4041

photoshop/api/action_manager/_main_types/action_descriptor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
from abc import abstractclassmethod
44
from typing import Any
55

6-
from ..utils import *
7-
from ._type_mapper import *
6+
from ..utils import str2id
7+
from ._type_mapper import pack
8+
from ._type_mapper import parsetype
9+
from ._type_mapper import unpack
810
from .action_descriptor_iterator import ActionDescriptor_Iterator
911

1012

11-
class ActionDescriptor:
13+
class ActionDescriptor(ABC):
1214
"""A vessel for my extra utils.
1315
You should not use, and cannot initialize it
1416
because it is an abstract class."""

photoshop/api/action_manager/_main_types/action_descriptor_iterator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
from ..utils import *
1+
from ..utils import id2str
22

33

44
class ActionDescriptor_Iterator:
55
"""An iterator. You don't need to initialize it manually."""
66

7-
def __init__(self, psobj: "ActionDescriptor"):
7+
def __init__(self, psobj):
88
self.curobj = psobj
99
self.n = -1
1010

1111
def __next__(self) -> str:
1212
self.n += 1
1313
try:
1414
keyid = self.curobj.getKey(self.n)
15-
except:
15+
except BaseException:
1616
raise StopIteration
1717
keystr = id2str(keyid)
1818
return keystr

photoshop/api/action_manager/_main_types/action_list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from abc import abstractclassmethod
44
from typing import Any
55

6-
from ..utils import *
7-
from ._type_mapper import *
6+
from ._type_mapper import pack
7+
from ._type_mapper import parsetype
8+
from ._type_mapper import unpack
89
from .action_list_iterator import ActionList_Iterator
910

1011

photoshop/api/action_manager/_main_types/action_list_iterator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
class ActionList_Iterator:
66
"""An iterator. You don't need to initialize it manually."""
77

8-
def __init__(self, psobj: "ActionList"):
8+
def __init__(self, psobj):
99
self.curobj = psobj
1010
self.n = -1
1111

1212
def __next__(self) -> Any:
1313
self.n += 1
1414
try:
1515
elem = self.curobj.uget(self.n)
16-
except:
16+
except BaseException:
1717
raise StopIteration()
1818
return elem
1919

photoshop/api/action_manager/_main_types/action_reference.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def uget(self, index: int) -> ReferenceKey:
2828
for i in range(index + 1):
2929
try:
3030
target = target.getContainer()
31-
except:
31+
except BaseException:
3232
raise IndexError("index out of range")
3333
return ReferenceKey._packer(target)
3434

@@ -42,7 +42,6 @@ def uput(self, rkey: ReferenceKey):
4242

4343
def dump(self) -> list:
4444
"""Convert an ActionReference to a python object."""
45-
target = self
4645
tlist = ["!ref"]
4746
tlist.extend([elem for elem in self])
4847
return tlist
@@ -54,7 +53,7 @@ def __len__(self):
5453
try:
5554
target = target.getContainer()
5655
rlen += 1
57-
except:
56+
except BaseException:
5857
rlen -= 1
5958
break
6059
return rlen

photoshop/api/action_manager/_main_types/action_reference_iterator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
class ActionReference_Iterator:
55
"""An iterator. You don't need to initialize it manually."""
66

7-
def __init__(self, psobj: "ActionReference"):
7+
def __init__(self, psobj):
88
self.curobj = psobj
99
self.init = True
1010
self.n = -1
@@ -17,7 +17,7 @@ def __next__(self) -> ReferenceKey:
1717
self.curobj = self.curobj.getContainer()
1818
try:
1919
self.curobj.getContainer()
20-
except:
20+
except BaseException:
2121
raise StopIteration
2222
return ReferenceKey._packer(self.curobj)
2323

photoshop/api/action_manager/desc_value_types/enumerated.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Import built-in modules
22
from collections import namedtuple
33

4-
from ..utils import *
4+
from ..utils import id2str
5+
from ..utils import str2id
56

67

78
Enumerated_proto = namedtuple("Enumerated_proto", ["type", "value"])

photoshop/api/action_manager/desc_value_types/typeid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Import built-in modules
22
from collections import namedtuple
33

4-
from ..utils import *
4+
from ..utils import id2str
5+
from ..utils import str2id
56

67

78
TypeID_proto = namedtuple("TypeID_proto", ["string"])

photoshop/api/action_manager/desc_value_types/unitdouble.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Import built-in modules
22
from collections import namedtuple
33

4-
from ..utils import *
4+
from ..utils import id2str
5+
from ..utils import str2id
56

67

78
UnitDouble_proto = namedtuple("UnitDouble_proto", ["unit", "double"])

photoshop/api/action_manager/jprint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def jformat(astr, indent=4, prefix=None):
5252
indent_level -= 1
5353
char = "\n" + " " * (indent * indent_level) + char
5454
nstr += char
55-
if not prefix is None:
55+
if prefix is not None:
5656
for kwd in all_am_keywords:
5757
nstr = nstr.replace(kwd, prefix + "." + kwd)
5858
return nstr
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
from .convert import dump
2+
3+
4+
__all__ = ["dump"]

photoshop/api/action_manager/js_converter/convert.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
# Import built-in modules
77
import json
88

9-
from ..desc_value_types import *
10-
from ..ref_form_types import *
11-
from ..utils import hash2str
9+
from ..desc_value_types import Enumerated
10+
from ..desc_value_types import TypeID
11+
from ..desc_value_types import UnitDouble
12+
from ..ref_form_types import Identifier
13+
from ..ref_form_types import Index
14+
from ..ref_form_types import Offset
15+
from ..ref_form_types import ReferenceKey
1216
from ..utils import id2str
1317
from ..utils import str2hash
14-
from ..utils import str2id
1518
from .injection_js import injection
1619
from .node_execjs import execjs
1720

@@ -59,7 +62,7 @@ def unhead(string):
5962

6063

6164
def parsedict(tdict):
62-
if not "_classID" in tdict:
65+
if "_classID" not in tdict:
6366
tdict["_classID"] = None
6467
else:
6568
tdict["_classID"] = unhead(tdict["_classID"])

photoshop/api/action_manager/js_converter/injection_js.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# flake8: noqa
2+
13
"""Defines injection, a variable which contains js code.
24
These js code implements Photoshop functions, and lures a piece of js code
35
to output all its information on executing executeAction function.

photoshop/api/action_manager/js_converter/node_execjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Node.js check
1010
nodestate = os.popen("node --version")
11-
if not re.match("^v\d*\.\d*\.\d*", nodestate.read()):
11+
if not re.match(r"^v\d*\.\d*\.\d*", nodestate.read()):
1212
raise RuntimeError("Please check if Node.js is installed to PATH!")
1313

1414

photoshop/api/action_manager/ref_form_types/_marker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ def __repr__(self):
1616
def __eq__(self, other):
1717
try:
1818
return self.name == other.name and self.value == other.value
19-
except:
19+
except BaseException:
2020
return False

photoshop/api/action_manager/ref_form_types/referencekey.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99

1010
from ..desc_value_types import Enumerated
1111
from ..desc_value_types import TypeID
12-
from ..utils import *
12+
from ..utils import id2str
13+
from ..utils import str2id
1314
from ._marker import marker
14-
from .identifier import Identifier
15-
from .index import Index
16-
from .offset import Offset
15+
16+
# Identifier, Index, Offset are used by getting them in globals().
17+
from .identifier import Identifier # noqa: F401
18+
from .index import Index # noqa: F401
19+
from .offset import Offset # noqa: F401
1720

1821

1922
psreftype2str = {
@@ -31,7 +34,7 @@ def _packer(cls, obj):
3134
dcls = id2str(obj.getDesiredClass())
3235
try:
3336
get_func = getattr(obj, "get" + ftype)
34-
except:
37+
except BaseException:
3538
get_func = None
3639
if ftype == "Class":
3740
v = None

photoshop/api/action_manager/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def str2id(psstr: str) -> str:
4242
typeid = str2hash(psstr)
4343
try:
4444
restr = converter.id2str(psstr)
45-
except:
45+
except BaseException:
4646
restr = ""
4747
if not restr:
4848
typeid = converter.str2id(psstr)

0 commit comments

Comments
 (0)