mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-28 05:11:04 -07:00
Add function typing
This allows MyPy to detect mistakes in the typing of these functions. Contributes to issue CURA-5330.
This commit is contained in:
parent
adafea73cc
commit
b9d47f6092
1 changed files with 4 additions and 4 deletions
|
|
@ -7,12 +7,12 @@ from typing import List, Optional
|
||||||
|
|
||||||
from PyQt5.QtNetwork import QLocalServer, QLocalSocket
|
from PyQt5.QtNetwork import QLocalServer, QLocalSocket
|
||||||
|
|
||||||
|
from UM.Application import Application #For typing.
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
|
|
||||||
class SingleInstance:
|
class SingleInstance:
|
||||||
|
def __init__(self, application: Application, files_to_open: Optional[List[str]]) -> None:
|
||||||
def __init__(self, application, files_to_open: Optional[List[str]]):
|
|
||||||
self._application = application
|
self._application = application
|
||||||
self._files_to_open = files_to_open
|
self._files_to_open = files_to_open
|
||||||
|
|
||||||
|
|
@ -64,14 +64,14 @@ class SingleInstance:
|
||||||
self._single_instance_server.newConnection.connect(self._onClientConnected)
|
self._single_instance_server.newConnection.connect(self._onClientConnected)
|
||||||
self._single_instance_server.listen("ultimaker-cura")
|
self._single_instance_server.listen("ultimaker-cura")
|
||||||
|
|
||||||
def _onClientConnected(self):
|
def _onClientConnected(self) -> None:
|
||||||
Logger.log("i", "New connection recevied on our single-instance server")
|
Logger.log("i", "New connection recevied on our single-instance server")
|
||||||
connection = self._single_instance_server.nextPendingConnection()
|
connection = self._single_instance_server.nextPendingConnection()
|
||||||
|
|
||||||
if connection is not None:
|
if connection is not None:
|
||||||
connection.readyRead.connect(lambda c = connection: self.__readCommands(c))
|
connection.readyRead.connect(lambda c = connection: self.__readCommands(c))
|
||||||
|
|
||||||
def __readCommands(self, connection):
|
def __readCommands(self, connection: QLocalSocket) -> None:
|
||||||
line = connection.readLine()
|
line = connection.readLine()
|
||||||
while len(line) != 0: # There is also a .canReadLine()
|
while len(line) != 0: # There is also a .canReadLine()
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue