Skip to content

Commit

Permalink
Merge pull request #3430 from janezd/fix-whitespace
Browse files Browse the repository at this point in the history
[MNT] PyLint: Fix whitespace-related issues
  • Loading branch information
lanzagar authored Dec 4, 2018
2 parents cf220bc + a92e1b5 commit cdfa54f
Show file tree
Hide file tree
Showing 96 changed files with 492 additions and 505 deletions.
2 changes: 1 addition & 1 deletion Orange/canvas/application/aboutdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __setupUi(self):
git_revision = "Unknown"

text = ABOUT_TEMPLATE.format(version=version,
git_revision=git_revision[:7])
git_revision=git_revision[:7])
# TODO: Also list all known add-on versions.
text_label = QLabel(text)
layout.addWidget(text_label, Qt.AlignCenter)
Expand Down
52 changes: 24 additions & 28 deletions Orange/canvas/application/canvasmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ def canvas_icons(name):
if icon_file.exists():
return QIcon("canvas_icons:" + name)
else:
return QIcon(pkg_resources.resource_filename(
config.__name__,
os.path.join("icons", name))
)
return QIcon(
pkg_resources.resource_filename(config.__name__,
os.path.join("icons", name))
)


class FakeToolBar(QToolBar):
Expand Down Expand Up @@ -193,10 +193,10 @@ def setup_ui(self):
log.info("Setting up Canvas main window.")

# Two dummy tool bars to reserve space
self.__dummy_top_toolbar = FakeToolBar(
objectName="__dummy_top_toolbar")
self.__dummy_bottom_toolbar = FakeToolBar(
objectName="__dummy_bottom_toolbar")
self.__dummy_top_toolbar = \
FakeToolBar(objectName="__dummy_top_toolbar")
self.__dummy_bottom_toolbar = \
FakeToolBar(objectName="__dummy_bottom_toolbar")

self.__dummy_top_toolbar.setFixedHeight(20)
self.__dummy_bottom_toolbar.setFixedHeight(20)
Expand Down Expand Up @@ -365,8 +365,7 @@ def touch():

self.help_dock = DockWidget(
self.tr("Help"), self, objectName="help-dock",
allowedAreas=Qt.RightDockWidgetArea |
Qt.BottomDockWidgetArea,
allowedAreas=Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea,
visible=False
)
if QWebEngineView is not None:
Expand Down Expand Up @@ -871,8 +870,8 @@ def set_widget_registry(self, widget_registry):
settings = QSettings()

state = settings.value("mainwindow/widgettoolbox/state",
defaultValue=QByteArray(),
type=QByteArray)
defaultValue=QByteArray(),
type=QByteArray)
if state:
self.widgets_tool_box.restoreState(state)

Expand Down Expand Up @@ -1186,21 +1185,20 @@ def new_scheme_from(self, filename):

except Exception:
message_critical(
self.tr("Could not load an Orange Workflow file"),
title=self.tr("Error"),
informative_text=self.tr("An unexpected error occurred "
"while loading '%s'.") % filename,
exc_info=True,
parent=self)
self.tr("Could not load an Orange Workflow file"),
title=self.tr("Error"),
informative_text=self.tr("An unexpected error occurred "
"while loading '%s'.") % filename,
exc_info=True,
parent=self)
return None
if errors:
message_warning(
self.tr("Errors occurred while loading the workflow."),
title=self.tr("Problem"),
informative_text=self.tr(
"There were problems loading some "
"of the widgets/links in the "
"workflow."
"There were problems loading some widgets/links"
"in the workflow."
),
details="\n".join(map(repr, errors))
)
Expand Down Expand Up @@ -1286,12 +1284,10 @@ def ask_save_changes(self):
document = self.current_document()
title = document.scheme().title or "untitled"
selected = message_question(
self.tr('Do you want to save the changes you made to workflow "%s"?')
% title,
self.tr('Save the changes to the workflow "%s"?') % title,
self.tr("Save Changes?"),
self.tr("Your changes will be lost if you do not save them."),
buttons=QMessageBox.Save | QMessageBox.Cancel | \
QMessageBox.Discard,
self.tr("Changes will be lost if they are not saved."),
buttons=QMessageBox.Save | QMessageBox.Cancel | QMessageBox.Discard,
default_button=QMessageBox.Save,
parent=self)

Expand Down Expand Up @@ -2087,8 +2083,8 @@ def __update_from_settings(self):
triggers |= SchemeEditWidget.DoubleClicked

right_click = settings.value("trigger-on-right-click",
defaultValue=True,
type=bool)
defaultValue=True,
type=bool)
if right_click:
triggers |= SchemeEditWidget.RightClicked

Expand Down
10 changes: 5 additions & 5 deletions Orange/canvas/application/schemeinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ def __setupUi(self):

check_layout.addWidget(self.__showAtNewSchemeCheck)
check_layout.addWidget(
QLabel(self.tr("You can also edit Workflow Info later "
"(File -> Workflow Info)."),
self,
objectName="auto-show-info"),
alignment=Qt.AlignRight)
QLabel(self.tr("You can also edit Workflow Info later "
"(File -> Workflow Info)."),
self,
objectName="auto-show-info"),
alignment=Qt.AlignRight)
widget.setLayout(check_layout)
widget.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
Expand Down
3 changes: 1 addition & 2 deletions Orange/canvas/application/welcomedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ def insertRow(self, index, actions, background="light-orange"):
for i, action in enumerate(actions):
self.insertAction(index, i, action, background)

def insertAction(self, row, index, action,
background="light-orange"):
def insertAction(self, row, index, action, background="light-orange"):
"""Insert `action` in `row` in position `index`.
"""
button = self.createButton(action, background)
Expand Down
10 changes: 6 additions & 4 deletions Orange/canvas/canvas/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,12 +789,14 @@ def items(self, *args, **kwargs):
return list(map(toGraphicsObjectIfPossible, items))

def selectedItems(self, *args, **kwargs):
return list(map(toGraphicsObjectIfPossible,
QGraphicsScene.selectedItems(self, *args, **kwargs)))
return [toGraphicsObjectIfPossible(obj)
for obj in
QGraphicsScene.selectedItems(self, *args, **kwargs)]

def collidingItems(self, *args, **kwargs):
return list(map(toGraphicsObjectIfPossible,
QGraphicsScene.collidingItems(self, *args, **kwargs)))
return [toGraphicsObjectIfPossible(obj)
for obj in
QGraphicsScene.collidingItems(self, *args, **kwargs)]

def focusItem(self, *args, **kwargs):
item = QGraphicsScene.focusItem(self, *args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion Orange/canvas/document/editlinksdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def mouseMoveEvent(self, event):
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton and self.__tmpLine:
endItem = find_item_at(self.scene(), event.scenePos(),
type=ChannelAnchor)
type=ChannelAnchor)

if endItem is not None:
startItem = self.__dragStartItem
Expand Down
44 changes: 22 additions & 22 deletions Orange/canvas/document/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ def mousePressEvent(self, event):
'an empty spot to create a new node.</p>'
'<p>Hold Shift when releasing the mouse button to '
'edit connections.</p>'
# '<a href="help://orange-canvas/create-new-links">'
# 'More ...</a>'
# '<a href="help://orange-canvas/create-new-links">'
# 'More ...</a>'
)
)
QCoreApplication.postEvent(self.document, helpevent)
Expand Down Expand Up @@ -562,11 +562,10 @@ def connect_nodes(self, source_node, sink_node):
raise UserCanceledError
else:
# links_to_add now needs to be a list of actual SchemeLinks
links_to_add = [scheme.SchemeLink(
source_node, source_channel,
sink_node, sink_channel)
for source_channel, sink_channel
in links_to_add]
links_to_add = [
scheme.SchemeLink(source_node, source_channel,
sink_node, sink_channel)
for source_channel, sink_channel in links_to_add]

links_to_add, links_to_remove = \
add_links_plan(self.scheme, links_to_add)
Expand Down Expand Up @@ -625,20 +624,21 @@ def edit_links(self, source_node, sink_node, initial_links=None):
)

if status == EditLinksDialog.Accepted:
links_to_add = [scheme.SchemeLink(
source_node, source_channel,
sink_node, sink_channel)
for source_channel, sink_channel in links_to_add]
links_to_add = [
scheme.SchemeLink(source_node, source_channel,
sink_node, sink_channel)
for source_channel, sink_channel in links_to_add]

links_to_remove = [self.scheme.find_links(
source_node, source_channel,
sink_node, sink_channel)
for source_channel, sink_channel
in links_to_remove]
links_to_remove = [
self.scheme.find_links(source_node, source_channel,
sink_node, sink_channel)
for source_channel, sink_channel in links_to_remove]

links_to_remove = reduce(list.__add__, links_to_remove, [])
conflicting = [_f for _f in [conflicting_single_link(self.scheme, link)
for link in links_to_add] if _f]
conflicting = [_f
for _f in [conflicting_single_link(self.scheme, link)
for link in links_to_add]
if _f]
for link in conflicting:
if link not in links_to_remove:
links_to_remove.append(link)
Expand Down Expand Up @@ -1069,8 +1069,8 @@ def start(self):
self.tr("Click and drag to create a new arrow"),
self.tr('<h3>New arrow annotation</h3>'
'<p>Click and drag to create a new arrow annotation.</p>'
# '<a href="help://orange-canvas/arrow-annotations>'
# 'More ...</a>'
# '<a href="help://orange-canvas/arrow-annotations>'
#'More ...</a>'
)
)
QCoreApplication.postEvent(self.document, helpevent)
Expand Down Expand Up @@ -1173,8 +1173,8 @@ def start(self):
self.tr('<h3>New text annotation</h3>'
'<p>Click (and drag to resize) on the canvas to create '
'a new text annotation item.</p>'
# '<a href="help://orange-canvas/text-annotations">'
# 'More ...</a>'
# '<a href="help://orange-canvas/text-annotations">'
# 'More ...</a>'
)
)
QCoreApplication.postEvent(self.document, helpevent)
Expand Down
16 changes: 7 additions & 9 deletions Orange/canvas/document/schemeedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,12 +1057,10 @@ def editNodeTitle(self, node):
Edit (rename) the `node`'s title. Opens an input dialog.
"""
name, ok = QInputDialog.getText(
self, self.tr("Rename"),
str(self.tr("Enter a new name for the '%s' widget")) \
% node.title,
text=node.title
)

self, self.tr("Rename"),
str(self.tr("Enter a new name for the '%s' widget")) % node.title,
text=node.title
)
if ok:
self.__undoStack.push(
commands.RenameNodeCommand(self.__scheme, node, node.title,
Expand Down Expand Up @@ -1744,9 +1742,9 @@ def copy_link(link, source=None, sink=None):

selection = self.selectedNodes()

links = [link for link in scheme.links
if link.source_node in selection and
link.sink_node in selection]
links = [
link for link in scheme.links
if link.source_node in selection and link.sink_node in selection]
nodedups = [copy_node(node) for node in selection]
allnames = {node.title for node in scheme.nodes + nodedups}
for nodedup in nodedups:
Expand Down
3 changes: 1 addition & 2 deletions Orange/canvas/document/tests/test_schemeedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def test_schemeedit(self):
scheme.annotation_added.connect(annot_list.append)
scheme.annotation_removed.connect(annot_list.remove)

node = SchemeNode(file_desc, title="title1",
position=(100, 100))
node = SchemeNode(file_desc, title="title1", position=(100, 100))
w.addNode(node)

self.assertSequenceEqual(node_list, [node])
Expand Down
6 changes: 3 additions & 3 deletions Orange/canvas/gui/dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def expanded(self):

def setWidget(self, w):
raise NotImplementedError(
"Please use the 'setExpandedWidget'/'setCollapsedWidget' "
"methods to set the contents of the dock widget."
)
"Use the 'setExpandedWidget'/'setCollapsedWidget' "
"methods to set the contents of the dock widget."
)

def setExpandedWidget(self, widget):
"""
Expand Down
16 changes: 8 additions & 8 deletions Orange/canvas/gui/dropshadow.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def paintEvent(self, event):
# Shadow casting rectangle in the source pixmap.
pixmap_shadow_rect = pixmap_rect.adjusted(left, top, -right, -bottom)
source_rects = self.__shadowPixmapFragments(pixmap_rect,
pixmap_shadow_rect)
pixmap_shadow_rect)
target_rects = self.__shadowPixmapFragments(shadow_rect, widget_rect)

painter = QPainter(self)
Expand Down Expand Up @@ -229,13 +229,13 @@ def __updatePixmap(self):
rect_fill_color = self.palette().color(QPalette.Window)

pixmap = render_drop_shadow_frame(
pixmap,
QRectF(shadow_rect),
shadow_color=self.color_,
offset=QPointF(0, 0),
radius=self.radius_,
rect_fill_color=rect_fill_color
)
pixmap,
QRectF(shadow_rect),
shadow_color=self.color_,
offset=QPointF(0, 0),
radius=self.radius_,
rect_fill_color=rect_fill_color
)

self.__shadowPixmap = pixmap
self.update()
Expand Down
2 changes: 1 addition & 1 deletion Orange/canvas/gui/splashscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from AnyQt.QtWidgets import QSplashScreen, QWidget, QApplication
from AnyQt.QtWidgets import QSplashScreen, QWidget, QApplication
from AnyQt.QtGui import (
QPixmap, QPainter, QTextDocument, QTextBlockFormat, QTextCursor
)
Expand Down
6 changes: 3 additions & 3 deletions Orange/canvas/gui/tests/test_splashscreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class TestSplashScreen(QAppTestCase):
def test_splashscreen(self):
splash = pkg_resources.resource_filename(
"Orange.canvas",
"icons/orange-splash-screen.png"
)
"Orange.canvas",
"icons/orange-splash-screen.png"
)

w = SplashScreen()
w.setPixmap(QPixmap(splash))
Expand Down
2 changes: 1 addition & 1 deletion Orange/canvas/gui/tests/test_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_tool_box(self):
self.assertIs(item, w.widget(i))
b = w.tabButton(i)
a = w.tabAction(i)
self.assertIsInstance(b, QAbstractButton)
self.assertIsInstance(b, QAbstractButton)
self.assertIs(b.defaultAction(), a)

w.show()
Expand Down
3 changes: 1 addition & 2 deletions Orange/canvas/gui/tests/test_tooltree.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def test_flattened(self):
item.setText("New text")

self.assertTrue(len(changed) == 1)
self.assertEqual(changed[-1][0].data(Qt.DisplayRole),
"New text")
self.assertEqual(changed[-1][0].data(Qt.DisplayRole), "New text")

self.assertEqual(model.data(model.index(1)), "New text")

Expand Down
2 changes: 1 addition & 1 deletion Orange/canvas/gui/toolgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections import namedtuple, deque

from AnyQt.QtWidgets import (
QFrame, QAction, QToolButton, QGridLayout, QSizePolicy,
QFrame, QAction, QToolButton, QGridLayout, QSizePolicy,
QStyleOptionToolButton, QStylePainter, QStyle
)
from AnyQt.QtGui import QFontMetrics
Expand Down
4 changes: 2 additions & 2 deletions Orange/canvas/gui/tooltree.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def eventFilter(self, obj, event):

space_activates = \
self.style().styleHint(
QStyle.SH_Menu_SpaceActivatesItem,
None, None)
QStyle.SH_Menu_SpaceActivatesItem,
None, None)

if key in [Qt.Key_Enter, Qt.Key_Return, Qt.Key_Select] or \
(key == Qt.Key_Space and space_activates):
Expand Down
Loading

0 comments on commit cdfa54f

Please sign in to comment.