Skip to content

Commit cc8145a

Browse files
committed
pylint
1 parent f123e5e commit cc8145a

File tree

5 files changed

+57
-23
lines changed

5 files changed

+57
-23
lines changed

Orange/canvas/__main__.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import pkg_resources
2121

2222
from AnyQt.QtGui import QFont, QColor, QPalette, QDesktopServices, QIcon
23-
from AnyQt.QtWidgets import QMessageBox
2423
from AnyQt.QtCore import (
2524
Qt, QDir, QUrl, QSettings, QThread, pyqtSignal, QT_VERSION
2625
)
@@ -195,15 +194,15 @@ def setup_notifications():
195194
"Would you like to take a short survey?",
196195
standardButtons=surveyDialogButtons)
197196

198-
def handle_response(button):
197+
def handle_survey_response(button):
199198
if surveyDialog.buttonRole(button) == NotificationWidget.AcceptRole:
200199
success = QDesktopServices.openUrl(
201200
QUrl("https://orange.biolab.si/survey/short.html"))
202201
settings["startup/show-short-survey"] = not success
203202
elif surveyDialog.buttonRole(button) == NotificationWidget.RejectRole:
204203
settings["startup/show-short-survey"] = False
205204

206-
surveyDialog.clicked.connect(handle_response)
205+
surveyDialog.clicked.connect(handle_survey_response)
207206

208207
NotificationOverlay.registerNotification(surveyDialog)
209208

@@ -221,13 +220,13 @@ def handle_response(button):
221220
btnOK = permDialog.button(NotificationWidget.AcceptRole)
222221
btnOK.setText("Allow")
223222

224-
def handle_response(button):
223+
def handle_permission_response(button):
225224
if permDialog.buttonRole(button) != permDialog.DismissRole:
226225
settings["error-reporting/permission-requested"] = True
227226
if permDialog.buttonRole(button) == permDialog.AcceptRole:
228227
settings["error-reporting/send-statistics"] = True
229228

230-
permDialog.clicked.connect(handle_response)
229+
permDialog.clicked.connect(handle_permission_response)
231230

232231
NotificationOverlay.registerNotification(permDialog)
233232

@@ -278,8 +277,6 @@ def compare_versions(latest):
278277
latest == skipped:
279278
return
280279

281-
from Orange.canvas.utils.overlay import NotificationWidget
282-
283280
questionButtons = NotificationWidget.Ok | NotificationWidget.Close
284281
question = NotificationWidget(icon=QIcon('Orange/widgets/icons/Dlg_down3.png'),
285282
title='Orange Update Available',
@@ -304,6 +301,7 @@ def handle_click(b):
304301
thread.resultReady.connect(compare_versions)
305302
thread.start()
306303
return thread
304+
return None
307305

308306

309307
def send_usage_statistics():

Orange/canvas/application/canvasmain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def user_documents_path():
5959
from ..gui.utils import message_critical, message_question, \
6060
message_warning, message_information
6161

62-
from ..utils.overlay import NotificationWidget, NotificationOverlay
62+
from ..utils.overlay import NotificationOverlay
6363

6464
from ..document.usagestatistics import UsageStatistics
6565

Orange/canvas/config.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,14 @@ def init():
117117
("quickmenu/trigger-on-any-key", bool, False,
118118
"Show quick menu on double click."),
119119

120-
("logging/level", int, 1, "Logging level"),
120+
("logging/level", int, 1,
121+
"Logging level"),
121122

122-
("logging/show-on-error", bool, True, "Show log window on error"),
123+
("logging/show-on-error", bool, True,
124+
"Show log window on error"),
123125

124-
("logging/dockable", bool, True, "Allow log window to be docked"),
126+
("logging/dockable", bool, True,
127+
"Allow log window to be docked"),
125128

126129
("help/open-in-external-browser", bool, False,
127130
"Open help in an external browser"),
@@ -141,9 +144,11 @@ def init():
141144
("add-ons/pip-install-arguments", str, '',
142145
'Arguments to pass to "pip install" when installing add-ons.'),
143146

144-
("network/http-proxy", str, '', 'HTTP proxy.'),
147+
("network/http-proxy", str, '',
148+
'HTTP proxy.'),
145149

146-
("network/https-proxy", str, '', 'HTTPS proxy.'),
150+
("network/https-proxy", str, '',
151+
'HTTPS proxy.'),
147152
]
148153

149154
spec = [config_slot(*t) for t in spec]

Orange/canvas/utils/overlay.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from collections import namedtuple
66

77
from AnyQt import QtGui
8-
from AnyQt.QtCore import Signal, Qt, QSize, QUrl
9-
from PyQt5.QtGui import QIcon, QPixmap, QDesktopServices, QPainter
10-
from PyQt5.QtWidgets import QAbstractButton, QHBoxLayout, QPushButton, QStyle, QWidget, \
8+
from AnyQt.QtCore import Signal, Qt, QSize
9+
from AnyQt.QtGui import QIcon, QPixmap, QPainter
10+
from AnyQt.QtWidgets import QAbstractButton, QHBoxLayout, QPushButton, QStyle, QWidget, \
1111
QVBoxLayout, QLabel, QSizePolicy, QStyleOption
1212

1313
from Orange.canvas.gui.stackedwidget import StackLayout
@@ -183,6 +183,34 @@ def textFormat(self):
183183
"""
184184
return self._textlabel.textFormat()
185185

186+
def setAcceptLabel(self, label):
187+
"""
188+
Set the accept button label.
189+
:type label: str
190+
"""
191+
self._acceptLabel = label
192+
193+
def acceptLabel(self):
194+
"""
195+
Return the accept button label.
196+
:rtype str
197+
"""
198+
return self._acceptLabel
199+
200+
def setRejectLabel(self, label):
201+
"""
202+
Set the reject button label.
203+
:type label: str
204+
"""
205+
self._rejectLabel = label
206+
207+
def rejectLabel(self):
208+
"""
209+
Return the reject button label.
210+
:rtype str
211+
"""
212+
return self._rejectLabel
213+
186214
def changeEvent(self, event):
187215
# reimplemented
188216
if event.type() == 177: # QEvent.MacSizeChange:
@@ -219,7 +247,7 @@ def addButton(self, button, *rolearg):
219247
"addButton(QAbstractButton, role)")
220248
role = rolearg[0]
221249
elif isinstance(button, NotificationMessageWidget.StandardButton):
222-
if len(rolearg) != 0:
250+
if rolearg:
223251
raise TypeError("Wrong number of arguments for "
224252
"addButton(StandardButton)")
225253
stdbutton = button
@@ -294,8 +322,7 @@ def button(self, standardButton):
294322
for slot in self._buttons:
295323
if slot.stdbutton == standardButton:
296324
return slot.button
297-
else:
298-
return None
325+
return None
299326

300327
def _button_clicked(self):
301328
button = self.sender()
@@ -390,12 +417,15 @@ def clone(self):
390417
textFormat=self._msgwidget.textFormat(),
391418
icon=self.icon(),
392419
standardButtons=self._msgwidget.standardButtons(),
393-
acceptLabel=self._msgwidget._acceptLabel,
394-
rejectLabel=self._msgwidget._rejectLabel)
420+
acceptLabel=self._msgwidget.acceptLabel(),
421+
rejectLabel=self._msgwidget.rejectLabel())
395422
cloned.accepted.connect(self.accepted)
396423
cloned.rejected.connect(self.rejected)
397424
cloned.dismissed.connect(self.dismissed)
398425

426+
# each canvas displays a clone of the original notification,
427+
# therefore the cloned buttons' events are connected to the original's
428+
# pylint: disable=protected-access
399429
button_map = dict(zip(
400430
[b.button for b in cloned._msgwidget._buttons] + [cloned._dismiss_button],
401431
[b.button for b in self._msgwidget._buttons] + [self._dismiss_button]))

Orange/canvas/utils/tests/test_overlay.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# pylint: disable=protected-access
2+
13
import unittest.mock
24

35
from AnyQt.QtCore import Qt, QEvent
@@ -73,7 +75,7 @@ def test_queued_notifications(self):
7375
standardButtons=surveyDialogButtons)
7476

7577
def handle_survey_response(b):
76-
self.assertEquals(self.notif.buttonRole(b), NotificationWidget.DismissRole)
78+
self.assertEqual(self.notif.buttonRole(b), NotificationWidget.DismissRole)
7779

7880
self.notif.clicked.connect(handle_survey_response)
7981

@@ -91,4 +93,3 @@ def handle_survey_response(b):
9193

9294
self.assertFalse(notif1.isVisible())
9395
self.assertTrue(notif2.isVisible())
94-

0 commit comments

Comments
 (0)