Skip to content

Commit 948c872

Browse files
committed
Merge branch 'improve_add_action' of https://github.com/ramses44/qtpy into improve_add_action
2 parents d6fa72d + 1a77685 commit 948c872

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

qtpy/_utils.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,32 @@ def add_action(self, *args, old_add_action):
8181
shortcut: QKeySequence | QKeySequence.StandardKey | str | int
8282

8383
# if args and isinstance(args[0], QIcon):
84-
if any(map(lambda arg: isinstance(arg, QIcon), args[:1])): # Better to use previous line instead of this
84+
if any(
85+
isinstance(arg, QIcon) for arg in args[:1]
86+
): # Better to use previous line instead of this
8587
icon, *args = args
8688
else:
8789
icon = QIcon()
8890

89-
if all(
90-
isinstance(arg, t)
91-
for arg, t in zip(
92-
args,
93-
[
94-
str,
95-
(QKeySequence, QKeySequence.StandardKey, str, int),
96-
QObject,
97-
bytes,
98-
],
91+
if (
92+
all(
93+
isinstance(arg, t)
94+
for arg, t in zip(
95+
args,
96+
[
97+
str,
98+
(QKeySequence, QKeySequence.StandardKey, str, int),
99+
QObject,
100+
bytes,
101+
],
102+
)
99103
)
104+
and len(args) >= 2
100105
):
101-
if len(args) >= 2:
102-
text, shortcut, *args = args
103-
action = old_add_action(self, icon, text, *args)
104-
action.setShortcut(shortcut)
105-
return action
106+
text, shortcut, *args = args
107+
action = old_add_action(self, icon, text, *args)
108+
action.setShortcut(shortcut)
109+
return action
106110

107111
return old_add_action(self, *args)
108112

0 commit comments

Comments
 (0)