Skip to content

Commit

Permalink
Fix typing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
don4get committed Nov 29, 2020
1 parent f3c37aa commit 7059f2c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ include_trailing_comma = True
force_grid_wrap=0
use_parentheses=True

known_third_party = PIL,PyQt5,PySide2,coloredlogs,graphene,numpy,pandas,pylab,pyqtconsole,pyqtgraph,pytest,pytestqt,recommonmark,scipy,setuptools,yaml
known_third_party = PIL,PyQt5,PySide2,black,coloredlogs,graphene,numpy,pandas,pylab,pyqtconsole,pyqtgraph,pytest,pytestqt,recommonmark,scipy,setuptools,yaml

16 changes: 13 additions & 3 deletions nodedge/editor_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from nodedge.graphics_view import GraphicsView
from nodedge.node import Node
from nodedge.scene import InvalidFile, Scene
from nodedge.socket_type import SocketType
from nodedge.utils import dumpException


Expand Down Expand Up @@ -269,13 +270,22 @@ def addNodes(self) -> None:
:class:`~nodedge.edge.Edge`.
"""
node1 = Node(
self.scene, "Node 1", inputSocketTypes=[1, 2, 3], outputSocketTypes=[1]
self.scene,
"Node 1",
inputSocketTypes=[SocketType.Any, SocketType.Number, SocketType.String],
outputSocketTypes=[SocketType.Any],
)
node2 = Node(
self.scene, "Node 2", inputSocketTypes=[1, 2, 3], outputSocketTypes=[1]
self.scene,
"Node 2",
inputSocketTypes=[SocketType.Any, SocketType.Number, SocketType.String],
outputSocketTypes=[SocketType.Any],
)
node3 = Node(
self.scene, "Node 3", inputSocketTypes=[1, 2, 3], outputSocketTypes=[1]
self.scene,
"Node 3",
inputSocketTypes=[SocketType.Any, SocketType.Number, SocketType.String],
outputSocketTypes=[SocketType.Any],
)

node1.pos = (-350, -250)
Expand Down
3 changes: 2 additions & 1 deletion nodedge/graphics_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def socketType(self) -> SocketType:
:return: socket type
:rtype: ``SocketType``
"""
return self.socket.socketType

return self.socket.socketType # type: ignore

# noinspection PyAttributeOutsideInit
def updateSocketType(self) -> None:
Expand Down
12 changes: 6 additions & 6 deletions nodedge/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ def __init__(
self,
scene: "Scene", # type: ignore
title: str = "Undefined node",
inputSocketTypes: Collection[int] = (),
outputSocketTypes: Collection[int] = (),
inputSocketTypes: Collection[SocketType] = (),
outputSocketTypes: Collection[SocketType] = (),
):
"""
:param scene: reference to the :class:`~nodedge.scene.Scene`
:type scene: :class:`~nodedge.scene.Scene`
:param title: node title shown in scene
:type title: ``str``
:param inputSocketTypes: list of types of the input `Sockets`
:type inputSocketTypes: ``Collection[int]``
:type inputSocketTypes: ``Collection[SocketType]``
:param outputSocketTypes: list of types of the output `Sockets`
:type outputSocketTypes: ``Collection[int]``
:type outputSocketTypes: ``Collection[SocketType]``
"""

super().__init__()
self._title: str = title
self.scene: "Scene" = scene # type: ignore
self.inputSocketTypes = inputSocketTypes
self.outputSocketTypes = outputSocketTypes
self.inputSocketTypes: Collection[SocketType] = inputSocketTypes
self.outputSocketTypes: Collection[SocketType] = outputSocketTypes

self.__logger = logging.getLogger(__file__)
self.__logger.setLevel(logging.INFO)
Expand Down
7 changes: 5 additions & 2 deletions nodedge/scene_item_detail_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SceneItemDetailWidget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.parent = parent
self.layout = QGridLayout()
self.layout: QGridLayout = QGridLayout()
self.layout.setAlignment(Qt.AlignTop)
self.setAutoFillBackground(True)

Expand All @@ -37,7 +37,10 @@ def addRow(self, title: str, edit: bool = False):
stringLabel.setAlignment(Qt.AlignTop)
stringLabel.setFixedHeight(30)

valueWidget: QWidget = QLineEdit("") if edit is True else QLabel("")
if edit is True:
valueWidget: QWidget = QLineEdit("")
else:
valueWidget = QLabel("")

valueWidget.setSizePolicy(
QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
Expand Down

0 comments on commit 7059f2c

Please sign in to comment.