Skip to content

Commit 707069a

Browse files
non-functional code-style fixes
1 parent 37d9373 commit 707069a

File tree

312 files changed

+2291
-2176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

312 files changed

+2291
-2176
lines changed

cura/API/Account.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2022 Ultimaker B.V.
22
# Cura is released under the terms of the LGPLv3 or higher.
3+
34
import enum
45
from datetime import datetime
56
import json
@@ -76,7 +77,7 @@ class Account(QObject):
7677
"library.project.read library.project.write cura.printjob.read cura.printjob.write " \
7778
"cura.mesh.read cura.mesh.write"
7879

79-
def __init__(self, application: "CuraApplication", parent = None) -> None:
80+
def __init__(self, application: "CuraApplication", parent=None) -> None:
8081
super().__init__(parent)
8182
self._application = application
8283
self._new_cloud_printers_detected = False
@@ -96,7 +97,7 @@ def __init__(self, application: "CuraApplication", parent = None) -> None:
9697
self._oauth_root = UltimakerCloudConstants.CuraCloudAccountAPIRoot
9798

9899
self._oauth_settings = OAuth2Settings(
99-
OAUTH_SERVER_URL= self._oauth_root,
100+
OAUTH_SERVER_URL=self._oauth_root,
100101
CALLBACK_PORT=self._callback_port,
101102
CALLBACK_URL="http://localhost:{}/callback".format(self._callback_port),
102103
CLIENT_ID="um----------------------------ultimaker_cura",
@@ -196,8 +197,8 @@ def _onLoginStateChanged(self, logged_in: bool = False, error_message: Optional[
196197
self._error_message.hide()
197198
Logger.log("w", "Failed to login: %s", error_message)
198199
self._error_message = Message(error_message,
199-
title = i18n_catalog.i18nc("@info:title", "Login failed"),
200-
message_type = Message.MessageType.ERROR)
200+
title=i18n_catalog.i18nc("@info:title", "Login failed"),
201+
message_type=Message.MessageType.ERROR)
201202
self._error_message.show()
202203
self._logged_in = False
203204
self.loginStateChanged.emit(False)
@@ -261,13 +262,13 @@ def login(self, force_logout_before_login: bool = False) -> None:
261262
return
262263
self._authorization_service.startAuthorizationFlow(force_logout_before_login)
263264

264-
@pyqtProperty(str, notify = userProfileChanged)
265+
@pyqtProperty(str, notify=userProfileChanged)
265266
def userName(self):
266267
if not self._user_profile:
267268
return ""
268269
return self._user_profile.username
269270

270-
@pyqtProperty(str, notify = userProfileChanged)
271+
@pyqtProperty(str, notify=userProfileChanged)
271272
def profileImageUrl(self):
272273
if not self._user_profile:
273274
return ""
@@ -277,7 +278,7 @@ def profileImageUrl(self):
277278
def accessToken(self) -> Optional[str]:
278279
return self._authorization_service.getAccessToken()
279280

280-
@pyqtProperty("QVariantMap", notify = userProfileChanged)
281+
@pyqtProperty("QVariantMap", notify=userProfileChanged)
281282
def userProfile(self) -> Dict[str, Optional[str]]:
282283
"""None if no user is logged in otherwise the logged in user as a dict containing containing user_id, username and profile_image_url """
283284
if not self._user_profile:
@@ -320,21 +321,21 @@ def logout(self) -> None:
320321

321322
self._authorization_service.deleteAuthData()
322323

323-
@deprecated("Get permissions from the 'permissions' property", since = "5.2.0")
324+
@deprecated("Get permissions from the 'permissions' property", since="5.2.0")
324325
def updateAdditionalRight(self, **kwargs) -> None:
325326
"""Update the additional rights of the account.
326327
The argument(s) are the rights that need to be set"""
327328
self._additional_rights.update(kwargs)
328329
self.additionalRightsChanged.emit(self._additional_rights)
329330

330-
@deprecated("Get permissions from the 'permissions' property", since = "5.2.0")
331-
@pyqtProperty("QVariantMap", notify = additionalRightsChanged)
331+
@deprecated("Get permissions from the 'permissions' property", since="5.2.0")
332+
@pyqtProperty("QVariantMap", notify=additionalRightsChanged)
332333
def additionalRights(self) -> Dict[str, Any]:
333334
"""A dictionary which can be queried for additional account rights."""
334335
return self._additional_rights
335336

336337
permissionsChanged = pyqtSignal()
337-
@pyqtProperty("QVariantList", notify = permissionsChanged)
338+
@pyqtProperty("QVariantList", notify=permissionsChanged)
338339
def permissions(self) -> List[str]:
339340
"""
340341
The permission keys that the user has in his account.
@@ -373,10 +374,10 @@ def error_callback(reply: "QNetworkReply", error: "QNetworkReply.NetworkError"):
373374
Logger.error(f"Request for user permissions list failed. Network error: {error}")
374375

375376
HttpRequestManager.getInstance().get(
376-
url = f"{self._oauth_root}/users/permissions",
377-
scope = JsonDecoratorScope(UltimakerCloudScope(self._application)),
378-
callback = callback,
379-
error_callback = error_callback,
380-
timeout = 10
377+
url=f"{self._oauth_root}/users/permissions",
378+
scope=JsonDecoratorScope(UltimakerCloudScope(self._application)),
379+
callback=callback,
380+
error_callback=error_callback,
381+
timeout=10
381382
)
382383

cura/API/Backups.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2018 Ultimaker B.V.
22
# Cura is released under the terms of the LGPLv3 or higher.
3+
34
from typing import Tuple, Optional, TYPE_CHECKING, Dict, Any
45

56
from cura.Backups.BackupsManager import BackupsManager

cura/API/ConnectionStatus.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) 2018 Ultimaker B.V.
2+
# Cura is released under the terms of the LGPLv3 or higher.
3+
14
from typing import Optional
25

36
from PyQt6.QtCore import QObject, pyqtSignal, pyqtProperty
@@ -30,12 +33,11 @@ def __init__(self, parent: Optional["QObject"] = None) -> None:
3033
self._is_internet_reachable = manager.isInternetReachable # type: bool
3134
manager.internetReachableChanged.connect(self._onInternetReachableChanged)
3235

33-
@pyqtProperty(bool, notify = internetReachableChanged)
36+
@pyqtProperty(bool, notify=internetReachableChanged)
3437
def isInternetReachable(self) -> bool:
3538
return self._is_internet_reachable
3639

3740
def _onInternetReachableChanged(self, reachable: bool):
3841
if reachable != self._is_internet_reachable:
3942
self._is_internet_reachable = reachable
4043
self.internetReachableChanged.emit()
41-

cura/API/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2018 Ultimaker B.V.
22
# Cura is released under the terms of the LGPLv3 or higher.
3+
34
from typing import Optional, TYPE_CHECKING
45

56
from PyQt6.QtCore import QObject, pyqtProperty
@@ -31,15 +32,15 @@ class CuraAPI(QObject):
3132
# Since the API is intended to be used by plugins, the cura application should have already created this.
3233
def __new__(cls, application: Optional["CuraApplication"] = None):
3334
if cls.__instance is not None:
34-
raise RuntimeError("Tried to create singleton '{class_name}' more than once.".format(class_name = CuraAPI.__name__))
35+
raise RuntimeError("Tried to create singleton '{class_name}' more than once.".format(class_name=CuraAPI.__name__))
3536
if application is None:
3637
raise RuntimeError("Upon first time creation, the application must be set.")
3738
instance = super(CuraAPI, cls).__new__(cls)
3839
cls._application = application
3940
return instance
4041

4142
def __init__(self, application: Optional["CuraApplication"] = None) -> None:
42-
super().__init__(parent = CuraAPI._application)
43+
super().__init__(parent=CuraAPI._application)
4344
CuraAPI.__instance = self
4445

4546
self._account = Account(self._application)
@@ -54,13 +55,13 @@ def __init__(self, application: Optional["CuraApplication"] = None) -> None:
5455
def initialize(self) -> None:
5556
self._account.initialize()
5657

57-
@pyqtProperty(QObject, constant = True)
58+
@pyqtProperty(QObject, constant=True)
5859
def account(self) -> "Account":
5960
"""Accounts API"""
6061

6162
return self._account
6263

63-
@pyqtProperty(QObject, constant = True)
64+
@pyqtProperty(QObject, constant=True)
6465
def connectionStatus(self) -> "ConnectionStatus":
6566
return self._connectionStatus
6667

cura/Arranging/ArrangeObjectsJob.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2019 Ultimaker B.V.
22
# Cura is released under the terms of the LGPLv3 or higher.
3+
34
from typing import List
45

56
from UM.Application import Application
@@ -26,10 +27,10 @@ def __init__(self, nodes: List[SceneNode], fixed_nodes: List[SceneNode], min_off
2627
def run(self):
2728
found_solution_for_all = False
2829
status_message = Message(i18n_catalog.i18nc("@info:status", "Finding new location for objects"),
29-
lifetime = 0,
30-
dismissable = False,
31-
progress = 0,
32-
title = i18n_catalog.i18nc("@info:title", "Finding Location"))
30+
lifetime=0,
31+
dismissable=False,
32+
progress=0,
33+
title=i18n_catalog.i18nc("@info:title", "Finding Location"))
3334
status_message.show()
3435

3536
if self._grid_arrange:
@@ -51,8 +52,8 @@ def run(self):
5152
no_full_solution_message = Message(
5253
i18n_catalog.i18nc("@info:status",
5354
"Unable to find a location within the build volume for all objects"),
54-
title = i18n_catalog.i18nc("@info:title", "Can't Find Location"),
55-
message_type = Message.MessageType.ERROR)
55+
title=i18n_catalog.i18nc("@info:title", "Can't Find Location"),
56+
message_type=Message.MessageType.ERROR)
5657
no_full_solution_message.show()
5758

5859
self.finished.emit(self)

cura/Arranging/Arranger.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) 2019 Ultimaker B.V.
2+
# Cura is released under the terms of the LGPLv3 or higher.
3+
14
from typing import List, TYPE_CHECKING, Optional, Tuple, Set
25

36
if TYPE_CHECKING:

cura/Arranging/GridArrange.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) 2019 Ultimaker B.V.
2+
# Cura is released under the terms of the LGPLv3 or higher.
3+
14
import math
25
from typing import List, TYPE_CHECKING, Tuple, Set, Union
36

cura/Arranging/ShapeArray.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ def fromNode(cls, node: "SceneNode", min_offset: float, scale: float = 0.5, incl
8888
offset_points = copy.deepcopy(offset_verts._points) # x, y
8989
offset_points[:, 0] = numpy.add(offset_points[:, 0], -transform_x)
9090
offset_points[:, 1] = numpy.add(offset_points[:, 1], -transform_y)
91-
offset_shape_arr = ShapeArray.fromPolygon(offset_points, scale = scale)
91+
offset_shape_arr = ShapeArray.fromPolygon(offset_points, scale=scale)
9292

9393
hull_points = copy.deepcopy(hull_verts._points)
9494
hull_points[:, 0] = numpy.add(hull_points[:, 0], -transform_x)
9595
hull_points[:, 1] = numpy.add(hull_points[:, 1], -transform_y)
96-
hull_shape_arr = ShapeArray.fromPolygon(hull_points, scale = scale) # x, y
96+
hull_shape_arr = ShapeArray.fromPolygon(hull_points, scale=scale) # x, y
9797

9898
return offset_shape_arr, hull_shape_arr
9999

@@ -110,7 +110,7 @@ def arrayFromPolygon(cls, shape: Union[Tuple[int, int], numpy.ndarray], vertices
110110
:return: numpy array with dimensions defined by shape
111111
"""
112112

113-
base_array = numpy.zeros(shape, dtype = numpy.int32) # type: ignore # Initialize your array of zeros
113+
base_array = numpy.zeros(shape, dtype=numpy.int32) # type: ignore # Initialize your array of zeros
114114

115115
fill = numpy.ones(base_array.shape) * True # Initialize boolean array defining shape fill
116116

cura/BackendPlugin.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) 2023 Ultimaker B.V.
22
# Cura is released under the terms of the LGPLv3 or higher.
3+
34
import socket
45
import os
56
import subprocess
@@ -100,22 +101,22 @@ def start(self) -> bool:
100101
Logger.log("e", f"Couldn't start EnginePlugin: {self._plugin_id} No permission to execute process.")
101102
self._showMessage(self.catalog.i18nc("@info:plugin_failed",
102103
f"Couldn't start EnginePlugin: {self._plugin_id}\nNo permission to execute process."),
103-
message_type = Message.MessageType.ERROR)
104+
message_type=Message.MessageType.ERROR)
104105
except FileNotFoundError:
105106
Logger.logException("e", f"Unable to find local EnginePlugin server executable for: {self._plugin_id}")
106107
self._showMessage(self.catalog.i18nc("@info:plugin_failed",
107108
f"Unable to find local EnginePlugin server executable for: {self._plugin_id}"),
108-
message_type = Message.MessageType.ERROR)
109+
message_type=Message.MessageType.ERROR)
109110
except BlockingIOError:
110111
Logger.logException("e", f"Couldn't start EnginePlugin: {self._plugin_id} Resource is temporarily unavailable")
111112
self._showMessage(self.catalog.i18nc("@info:plugin_failed",
112113
f"Couldn't start EnginePlugin: {self._plugin_id}\nResource is temporarily unavailable"),
113-
message_type = Message.MessageType.ERROR)
114+
message_type=Message.MessageType.ERROR)
114115
except OSError as e:
115116
Logger.logException("e", f"Couldn't start EnginePlugin {self._plugin_id} Operating system is blocking it (antivirus?)")
116117
self._showMessage(self.catalog.i18nc("@info:plugin_failed",
117118
f"Couldn't start EnginePlugin: {self._plugin_id}\nOperating system is blocking it (antivirus?)"),
118-
message_type = Message.MessageType.ERROR)
119+
message_type=Message.MessageType.ERROR)
119120
return False
120121

121122
def stop(self) -> bool:
@@ -133,9 +134,8 @@ def stop(self) -> bool:
133134
Logger.log("e", f"Unable to kill running EnginePlugin: {self._plugin_id} Access is denied.")
134135
self._showMessage(self.catalog.i18nc("@info:plugin_failed",
135136
f"Unable to kill running EnginePlugin: {self._plugin_id}\nAccess is denied."),
136-
message_type = Message.MessageType.ERROR)
137+
message_type=Message.MessageType.ERROR)
137138
return False
138139

139140
def _showMessage(self, message: str, message_type: Message.MessageType = Message.MessageType.ERROR) -> None:
140-
Message(message, title=self.catalog.i18nc("@info:title", "EnginePlugin"), message_type = message_type).show()
141-
141+
Message(message, title=self.catalog.i18nc("@info:title", "EnginePlugin"), message_type=message_type).show()

cura/Backups/Backup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ def _makeArchive(self, buffer: "io.BytesIO", root_path: str) -> Optional[ZipFile
113113
Logger.log("e", "Could not create archive from user data directory: %s", error)
114114
self._showMessage(self.catalog.i18nc("@info:backup_failed",
115115
"Could not create archive from user data directory: {}".format(error)),
116-
message_type = Message.MessageType.ERROR)
116+
message_type=Message.MessageType.ERROR)
117117
return None
118118

119119
def _showMessage(self, message: str, message_type: Message.MessageType = Message.MessageType.NEUTRAL) -> None:
120120
"""Show a UI message."""
121121

122-
Message(message, title=self.catalog.i18nc("@info:title", "Backup"), message_type = message_type).show()
122+
Message(message, title=self.catalog.i18nc("@info:title", "Backup"), message_type=message_type).show()
123123

124124
def restore(self) -> bool:
125125
"""Restore this back-up.
@@ -132,18 +132,18 @@ def restore(self) -> bool:
132132
Logger.log("w", "Tried to restore a Cura backup without having proper data or meta data.")
133133
self._showMessage(self.catalog.i18nc("@info:backup_failed",
134134
"Tried to restore a Cura backup without having proper data or meta data."),
135-
message_type = Message.MessageType.ERROR)
135+
message_type=Message.MessageType.ERROR)
136136
return False
137137

138138
current_version = Version(self._application.getVersion())
139139
version_to_restore = Version(self.meta_data.get("cura_release", "dev"))
140140

141141
if current_version < version_to_restore:
142142
# Cannot restore version newer than current because settings might have changed.
143-
Logger.log("d", "Tried to restore a Cura backup of version {version_to_restore} with cura version {current_version}".format(version_to_restore = version_to_restore, current_version = current_version))
143+
Logger.log("d", "Tried to restore a Cura backup of version {version_to_restore} with cura version {current_version}".format(version_to_restore=version_to_restore, current_version=current_version))
144144
self._showMessage(self.catalog.i18nc("@info:backup_failed",
145145
"Tried to restore a Cura backup that is higher than the current version."),
146-
message_type = Message.MessageType.ERROR)
146+
message_type=Message.MessageType.ERROR)
147147
return False
148148

149149
# Get the current secrets and store since the back-up doesn't contain those
@@ -156,8 +156,8 @@ def restore(self) -> bool:
156156
Logger.log("d", f"The following error occurred while trying to restore a Cura backup: {str(e)}")
157157
Message(self.catalog.i18nc("@info:backup_failed",
158158
"The following error occurred while trying to restore a Cura backup:") + str(e),
159-
title = self.catalog.i18nc("@info:title", "Backup"),
160-
message_type = Message.MessageType.ERROR).show()
159+
title=self.catalog.i18nc("@info:title", "Backup"),
160+
message_type=Message.MessageType.ERROR).show()
161161

162162
return False
163163
extracted = self._extractArchive(archive, version_data_dir)

cura/Backups/BackupsManager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ def restoreBackup(self, zip_file: bytes, meta_data: Dict[str, str]) -> None:
5151

5252
self._disableAutoSave()
5353

54-
backup = Backup(self._application, zip_file = zip_file, meta_data = meta_data)
54+
backup = Backup(self._application, zip_file=zip_file, meta_data=meta_data)
5555
restored = backup.restore()
5656

5757
if restored:
5858
# At this point, Cura will need to restart for the changes to take effect.
5959
# We don't want to store the data at this point as that would override the just-restored backup.
60-
self._application.windowClosed(save_data = False)
60+
self._application.windowClosed(save_data=False)
6161

6262
def _disableAutoSave(self) -> None:
6363
"""Here we (try to) disable the saving as it might interfere with restoring a back-up."""

0 commit comments

Comments
 (0)