From 8bebc4f692056aad69e4bac28c175730565e0f3f Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:19:40 +0100 Subject: [PATCH] refactor: pylint improvement --- bec_widgets/widgets/motor_map/motor_map.py | 21 ++++++++++++++++++--- tests/test_motor_map.py | 3 ++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bec_widgets/widgets/motor_map/motor_map.py b/bec_widgets/widgets/motor_map/motor_map.py index cb2c17cf..bbc2f940 100644 --- a/bec_widgets/widgets/motor_map/motor_map.py +++ b/bec_widgets/widgets/motor_map/motor_map.py @@ -1,3 +1,4 @@ +# pylint: disable = no-name-in-module,missing-module-docstring from __future__ import annotations import time @@ -80,6 +81,20 @@ class MotorMap(pg.GraphicsLayoutWidget): self.update_signal, rateLimit=25, slot=self._update_plots ) + # Config related variables + self.plot_data = None + self.plot_settings = None + self.max_points = None + self.num_dim_points = None + self.scatter_size = None + self.precision = None + self.background_value = None + self.database = {} + self.device_mapping = {} + self.plots = {} + self.grid_coordinates = [] + self.curves_data = {} + # Init UI with config if self.config is None: print("No initial config found for MotorMap. Using default config.") @@ -190,7 +205,7 @@ class MotorMap(pg.GraphicsLayoutWidget): motor_limits = self._get_motor_limit(motor_name) signal["limits"] = motor_limits - def _get_motor_limit(self, motor: str) -> Union[Any | None]: + def _get_motor_limit(self, motor: str) -> Union[list | None]: """ Get the motor limit from the config. Args: @@ -203,11 +218,11 @@ class MotorMap(pg.GraphicsLayoutWidget): limits = self.dev[motor].limits if limits == [0, 0]: return None - else: - return limits + return limits except AttributeError: # TODO maybe not needed, if no limits it returns [0,0] # If the motor doesn't have a 'limits' attribute, return a default value or raise a custom exception print(f"The device '{motor}' does not have defined limits.") + return None def _init_database(self): """Initiate the database according the config.""" diff --git a/tests/test_motor_map.py b/tests/test_motor_map.py index 1af9b875..04da110c 100644 --- a/tests/test_motor_map.py +++ b/tests/test_motor_map.py @@ -1,5 +1,6 @@ -import pytest +# pylint: disable = no-name-in-module,missing-module-docstring, missing-function-docstring from unittest.mock import MagicMock +import pytest from bec_widgets.widgets import MotorMap