Skip to content

Commit

Permalink
Project-wide trime of whitespace in entire project
Browse files Browse the repository at this point in the history
To bring code up to standards with what was discussed here:
Ultimaker/Cura#7551 (comment)
  • Loading branch information
ninovanhooff committed Jun 2, 2020
1 parent 463020c commit 9810a3d
Show file tree
Hide file tree
Showing 107 changed files with 769 additions and 771 deletions.
8 changes: 4 additions & 4 deletions UM/Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
@signalemitter
class Application:
"""Central object responsible for running the main event loop and creating other central objects.
The Application object is a central object for accessing other important objects. It is also
responsible for starting the main event loop. It is passed on to plugins so it can be easily
used to access objects required for those plugins.
"""

def __init__(self, name: str, version: str, api_version: str, app_display_name: str = "", build_type: str = "", is_debug_mode: bool = False, **kwargs) -> None:
"""Init method
:param name: :type{string} The name of the application.
:param version: :type{string} Version, formatted as major.minor.rev
:param build_type: Additional version info on the type of build this is, such as "master".
Expand Down Expand Up @@ -420,7 +420,7 @@ def getRenderer(self) -> Renderer:

def functionEvent(self, event: CallFunctionEvent) -> None:
"""Post a function event onto the event loop.
This takes a CallFunctionEvent object and puts it into the actual event loop.
:exception NotImplementedError
"""
Expand All @@ -429,7 +429,7 @@ def functionEvent(self, event: CallFunctionEvent) -> None:

def callLater(self, func: Callable[..., Any], *args, **kwargs) -> None:
"""Call a function the next time the event loop runs.
You can't get the result of this function directly. It won't block.
:param func: The function to call.
:param args: The positional arguments to pass to the function.
Expand Down
6 changes: 3 additions & 3 deletions UM/Backend/Backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def getLog(self):
while len(self._backend_log) >= self._backend_log_max_lines:
del(self._backend_log[0])
return self._backend_log

def getEngineCommand(self):
"""Get the command used to start the backend executable """

Expand Down Expand Up @@ -207,7 +207,7 @@ def _onMessageReceived(self):
return

self._message_handlers[message.getTypeName()](message)

def _onSocketError(self, error):
"""Private socket error handler"""

Expand Down Expand Up @@ -243,7 +243,7 @@ def _createSocket(self, protocol_file):
self._socket.stateChanged.connect(self._onSocketStateChanged)
self._socket.messageReceived.connect(self._onMessageReceived)
self._socket.error.connect(self._onSocketError)

if Platform.isWindows():
# On Windows, the Protobuf DiskSourceTree does stupid things with paths.
# So convert to forward slashes here so it finds the proto file properly.
Expand Down
2 changes: 1 addition & 1 deletion UM/Backend/SignalSocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def stateChanged(self, state):
# For some reason, every so often, it seems to feel that the attribute stateChangedCallback doesn't exist.
# Ignoring this prevents crashes.
pass

def messageReceived(self):
if self.messageReceivedCallback:
self.messageReceivedCallback()
Expand Down
2 changes: 1 addition & 1 deletion UM/ConfigurationErrorMessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class ConfigurationErrorMessage(Message):
"""This is a specialised message that shows errors in the configuration.
This class coalesces all errors in the configuration. Whenever there are new
errors the message gets updated (and shown if it was hidden).
"""
Expand Down
6 changes: 3 additions & 3 deletions UM/Controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@signalemitter
class Controller:
"""Glue class that holds the scene, (active) view(s), (active) tool(s) and possible user inputs.
The different types of views / tools / inputs are defined by plugins.
:sa View
:sa Tool
Expand Down Expand Up @@ -361,14 +361,14 @@ def setActiveTool(self, tool: Optional[Union["Tool", str]]):

toolOperationStarted = Signal()
"""Emitted whenever a tool starts a longer operation.
:param tool: The tool that started the operation.
:sa Tool::startOperation
"""

toolOperationStopped = Signal()
"""Emitted whenever a tool stops a longer operation.
:param tool: The tool that stopped the operation.
:sa Tool::stopOperation
"""
Expand Down
12 changes: 6 additions & 6 deletions UM/Decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def deprecated(message, since = "Unknown"): #pylint: disable=bad-whitespace
"""Decorator that can be used to indicate a method has been deprecated
:param message: The message to display when the method is called. Should include a suggestion about what to use.
:param since: A version since when this method has been deprecated.
"""
Expand All @@ -29,7 +29,7 @@ def deprecated_function(*args, **kwargs):

def ascopy(function):
"""Decorator to ensure the returned value is always a copy and never a direct reference
"Everything is a Reference" is not nice when dealing with value-types like a Vector or Matrix.
Since you hardly ever want to manipulate internal state of for example a SceneNode, most get methods
should return a copy instead of the actual object. This decorator ensures that happens.
Expand All @@ -43,7 +43,7 @@ def copy_function(*args, **kwargs):

def call_if_enabled(function: Callable[..., Any], condition: bool) -> Callable[..., Any]:
"""Decorator to conditionally call an extra function before calling the actual function.
This is primarily intended for conditional debugging, to make it possible to add extra
debugging before calling a function that is only enabled when you actually want to
debug things.
Expand Down Expand Up @@ -71,9 +71,9 @@ class InvalidOverrideError(Exception):

def override(cls):
"""Function decorator that can be used to mark a function as an override.
This works basically the same as the override attribute in C++ functions.
:param cls: The class this function overrides a function from.
"""

Expand All @@ -86,7 +86,7 @@ def override_decorator(function):

def interface(cls):
"""Class decorator that checks to see if all methods of the base class have been reimplemented
This is meant as a simple sanity check. An interface here is defined as a class with
only functions. Any subclass is expected to reimplement all functions defined in the class,
excluding builtin functions like __getattr__. It is also expected to match the signature of
Expand Down
6 changes: 3 additions & 3 deletions UM/Dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

def findKey(dictionary: Dict[Any, Any], search_value: Any) -> Any:
"""Find the key corresponding to a certain value
:param dictionary: :type{dict} The dictionary to search for the value
:param search_value: The value to search for.
:return: The key matching to value. Note that if the dictionary contains multiple instances of value it is undefined which exact key is returned.
:exception ValueError: is raised when the value is not found in the dictionary.
"""

Expand Down
12 changes: 6 additions & 6 deletions UM/Event.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class WheelEvent(MouseEvent):

def __init__(self, horizontal: int, vertical: int, x: int = 0, y: int = 0) -> None:
"""Create a new scroll wheel event.
:param horizontal: How far the scroll wheel scrolled horizontally, in
eighths of a degree. To the right is positive. To the left is negative.
:param vertical: How far the scroll wheel scrolled vertically, in eighths
Expand All @@ -136,7 +136,7 @@ def __init__(self, horizontal: int, vertical: int, x: int = 0, y: int = 0) -> No
def horizontal(self) -> int:
"""How far the scroll wheel was scrolled horizontally, in eighths of a
degree.
To the right is positive. To the left is negative.
"""

Expand All @@ -146,7 +146,7 @@ def horizontal(self) -> int:
def vertical(self) -> int:
"""How far the scroll wheel was scrolled vertically, in eighths of a
degree.
Up is positive. Down is negative.
"""

Expand All @@ -155,12 +155,12 @@ def vertical(self) -> int:

class KeyEvent(Event):
"""Event regarding the keyboard.
These events are raised when anything changes in the keyboard state. They
keep track of the event type that was given by Qt, for instance whether it
was a KeyPressEvent or a KeyReleaseEvent, and they keep track of which key
it was.
Only the special keys are tracked (Shirt, Space, Escape, etc.), not the
normal letter keys.
"""
Expand Down Expand Up @@ -192,7 +192,7 @@ def __init__(self, event_type: int, key: int) -> None:
@property
def key(self) -> int:
"""Which key was pressed.
Compare this with `KeyEvent.AltKey`, `KeyEvent.EnterKey`, etc.
"""

Expand Down
3 changes: 1 addition & 2 deletions UM/FileHandler/FileHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class FileHandler(QObject):
This class is created by Application and handles reading and writing mesh files.
"""


def __init__(self, application: "QtApplication", writer_type: str = "unknown_file_writer", reader_type: str = "unknown_file_reader", parent: QObject = None) -> None:
if cast(FileHandler, self.__class__).__instance is not None:
raise RuntimeError("Try to create singleton '%s' more than once" % self.__class__.__name__)
Expand Down Expand Up @@ -135,7 +134,7 @@ def readerRead(self, reader, file_name: str, **kwargs: Any):

def getWriterByMimeType(self, mime: str) -> Optional["FileWriter"]:
"""Get a mesh writer object that supports writing the specified mime type
:param mime: The mime type that should be supported.
:return: A FileWriter instance or None if no mesh writer supports the specified mime type. If there are multiple
writers that support the specified mime type, the first entry is returned.
Expand Down
6 changes: 3 additions & 3 deletions UM/FileHandler/FileReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self) -> None:

def acceptsFile(self, file_name):
"""Returns true if file_name can be processed by this plugin.
:return: boolean indication if this plugin accepts the file specified.
"""

Expand All @@ -39,15 +39,15 @@ def preRead(self, file_name, *args, **kwargs):
"""Executed before reading the file. This is used, for example, to display an import
configuration dialog. If a plugin displays such a dialog,
this function should block until it has been closed.
:return: indicating if the user accepted or canceled the dialog.
"""

return FileReader.PreReadResult.accepted

def read(self, file_name):
"""Read mesh data from file and returns a node that contains the data
:return: data read.
"""

Expand Down
4 changes: 2 additions & 2 deletions UM/FileHandler/WriteFileJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

class WriteFileJob(Job):
"""A Job subclass that performs writing.
The writer defines what the result of this job is.
"""

def __init__(self, writer: Optional[FileWriter], stream: Union[io.BytesIO, io.StringIO], data: Any, mode: int) -> None:
"""Creates a new job for writing.
:param writer: The file writer to use, with the correct MIME type.
:param stream: The output stream to write to.
:param data: Whatever it is what we want to write.
Expand Down
8 changes: 4 additions & 4 deletions UM/FlameProfiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _plainToJSON(self):

def getProfileData():
"""Fetch the accumulated profile data.
:return: :type{ProfileCallNode} or None if there is no data.
"""

Expand Down Expand Up @@ -144,7 +144,7 @@ def secondsToMS(value):
@contextmanager
def profileCall(name):
"""Profile a block of code.
Use this context manager to wrap and profile a block of code.
:param name: :type{str} The name to use to identify this code in the profile report.
"""
Expand All @@ -166,7 +166,7 @@ def profileCall(name):

def isRecordingProfile() -> bool:
"""Return whether we are recording profiling information.
:return: :type{bool} True if we are recording.
"""

Expand Down Expand Up @@ -216,7 +216,7 @@ def runIt(*args, ** kwargs):

def pyqtSlot(*args, **kwargs) -> Callable[..., Any]:
"""Drop in replacement for PyQt5's pyqtSlot decorator which records profiling information.
See the PyQt5 documentation for information about pyqtSlot.
"""

Expand Down
2 changes: 1 addition & 1 deletion UM/InputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self) -> None:

event = Signal()
"""Emitted whenever the device produces an event.
All actions performed with the device should be seen as an event.
:param event: The event that is emitted.
"""
Loading

0 comments on commit 9810a3d

Please sign in to comment.