From 215bbcea4d63f44bc250e73490ec7781d343fd79 Mon Sep 17 00:00:00 2001 From: Drew Devereux <drew.devereux@csiro.au> Date: Mon, 31 May 2021 00:26:56 +0000 Subject: [PATCH] [MCCS-585] Linting fixes from move to flake8 --- src/ska_tango_base/base/base_device.py | 18 +++++++++--------- src/ska_tango_base/base/component_manager.py | 2 +- src/ska_tango_base/commands.py | 2 +- src/ska_tango_base/csp/obs/obs_device.py | 4 ++-- src/ska_tango_base/csp/obs/obs_state_model.py | 2 +- .../csp/obs/reference_component_manager.py | 2 -- .../csp/subarray/subarray_device.py | 12 ++++++++---- src/ska_tango_base/obs/obs_device.py | 2 -- .../subarray/reference_component_manager.py | 2 -- src/ska_tango_base/subarray/subarray_device.py | 9 +++------ .../subarray/subarray_obs_state_model.py | 2 +- tests/conftest.py | 1 - tests/test_alarm_handler_device.py | 5 ++++- tests/test_csp_subarray.py | 6 +++--- 14 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/ska_tango_base/base/base_device.py b/src/ska_tango_base/base/base_device.py index f0e5a84b..005d1d9c 100644 --- a/src/ska_tango_base/base/base_device.py +++ b/src/ska_tango_base/base/base_device.py @@ -498,7 +498,7 @@ class SKABaseDevice(Device): SkaLevel = device_property(dtype="int16", default_value=4) """ Device property. - + Indication of importance of the device in the SKA hierarchy to support drill-down navigation: 1..6, with 1 highest. """ @@ -508,15 +508,15 @@ class SKABaseDevice(Device): ) """ Device property. - + Each string in the list is a JSON serialised dict defining the ``group_name``, ``devices`` and ``subgroups`` in the group. A Tango Group object is created for each item in the list, according to the hierarchy defined. This provides easy access to the managed devices in bulk, or individually. - + The general format of the list is as follows, with optional ``devices`` and ``subgroups`` keys:: - + [ {"group_name": "<name>", "devices": ["<dev name>", ...]}, {"group_name": "<name>", @@ -525,9 +525,9 @@ class SKABaseDevice(Device): {<nested group>}, ...]}, ... ] - + For example, a hierarchy of racks, servers and switches:: - + [ {"group_name": "servers", "devices": ["elt/server/1", "elt/server/2", "elt/server/3", "elt/server/4"]}, @@ -553,7 +553,7 @@ class SKABaseDevice(Device): ) """ Device property. - + Default logging level at device startup. See :py:class:`~ska_tango_base.control_model.LoggingLevel` """ @@ -563,7 +563,7 @@ class SKABaseDevice(Device): ) """ Device property. - + Default logging targets at device startup. See the project readme for details. """ @@ -592,7 +592,7 @@ class SKABaseDevice(Device): ) """ Device attribute. - + See :py:class:`~ska_tango_base.control_model.LoggingLevel` """ diff --git a/src/ska_tango_base/base/component_manager.py b/src/ska_tango_base/base/component_manager.py index 2b84a482..049fcc1f 100644 --- a/src/ska_tango_base/base/component_manager.py +++ b/src/ska_tango_base/base/component_manager.py @@ -12,7 +12,7 @@ The basic model is: * A software routine, possibly implemented within the Tango device itself - + * In a hierarchical system, a pool of lower-level Tango devices. * A Tango device will usually need to establish and maintain a diff --git a/src/ska_tango_base/commands.py b/src/ska_tango_base/commands.py index ea50f7a8..ac28b9ec 100644 --- a/src/ska_tango_base/commands.py +++ b/src/ska_tango_base/commands.py @@ -19,7 +19,7 @@ The following command classes are provided: * **ResponseCommand**: for commands that return a ``(ResultCode, message)`` tuple. - + * **CompletionCommand**: for commands that need to let their state machine know when they have completed; that is, long-running commands with transitional states, such as ``AssignResources()`` and diff --git a/src/ska_tango_base/csp/obs/obs_device.py b/src/ska_tango_base/csp/obs/obs_device.py index bc86a53a..a4d9bf49 100644 --- a/src/ska_tango_base/csp/obs/obs_device.py +++ b/src/ska_tango_base/csp/obs/obs_device.py @@ -218,13 +218,13 @@ class CspSubElementObsDevice(SKAObsDevice): def read_scanID(self): # PROTECTED REGION ID(CspSubElementObsDevice.scanID_read) ENABLED START # """Return the scanID attribute.""" - return self.component_manager.scan_id # pylint: disable=no-member + return self.component_manager.scan_id # PROTECTED REGION END # // CspSubElementObsDevice.scanID_read def read_configurationID(self): # PROTECTED REGION ID(CspSubElementObsDevice.configurationID_read) ENABLED START # """Return the configurationID attribute.""" - return self.component_manager.config_id # pylint: disable=no-member + return self.component_manager.config_id # PROTECTED REGION END # // CspSubElementObsDevice.configurationID_read def read_deviceID(self): diff --git a/src/ska_tango_base/csp/obs/obs_state_model.py b/src/ska_tango_base/csp/obs/obs_state_model.py index e594bd8c..b9a8bb47 100644 --- a/src/ska_tango_base/csp/obs/obs_state_model.py +++ b/src/ska_tango_base/csp/obs/obs_state_model.py @@ -8,7 +8,7 @@ comprises: * a :py:class:`.CspSubElementObsStateModel` that maps the underlying state machine state to a value of the :py:class:`ska_tango_base.control_model.ObsState` enum. - + """ from transitions.extensions import LockedMachine as Machine diff --git a/src/ska_tango_base/csp/obs/reference_component_manager.py b/src/ska_tango_base/csp/obs/reference_component_manager.py index 8d367156..220176d1 100644 --- a/src/ska_tango_base/csp/obs/reference_component_manager.py +++ b/src/ska_tango_base/csp/obs/reference_component_manager.py @@ -3,8 +3,6 @@ This module models component management for CSP subelement observation devices. """ import functools -from tango import DevState - from ska_tango_base.csp.obs import CspObsComponentManager from ska_tango_base.base import check_communicating, ReferenceBaseComponentManager diff --git a/src/ska_tango_base/csp/subarray/subarray_device.py b/src/ska_tango_base/csp/subarray/subarray_device.py index a4affd9b..94cbadc2 100644 --- a/src/ska_tango_base/csp/subarray/subarray_device.py +++ b/src/ska_tango_base/csp/subarray/subarray_device.py @@ -72,7 +72,9 @@ class CspSubElementSubarray(SKASubarray): dtype="DevString", access=AttrWriteType.READ_WRITE, label="sdpDestinationAddresses", - doc="JSON formatted string.\nReport the list of all the SDP addresses provided by SDP to receive the output products.\nSpecifies the Mac, IP, Port for each resource:CBF visibility channels, Pss pipelines, PSTBeam", + doc="JSON formatted string.\nReport the list of all the SDP addresses provided " + "by SDP to receive the output products.\nSpecifies the Mac, IP, Port for each " + "resource:CBF visibility channels, Pss pipelines, PSTBeam", ) """Device attribute.""" @@ -102,7 +104,9 @@ class CspSubElementSubarray(SKASubarray): listOfDevicesCompletedTasks = attribute( dtype="DevString", label="listOfDevicesCompletedTasks", - doc="JSON formatted string reporting for each task/command the list of devices\nthat completed successfully the task.\nEx.\n{``cmd1``: [``device1``, ``device2``], ``cmd2``: [``device2``, ``device3``]}", + doc="JSON formatted string reporting for each task/command the list of devices" + "\nthat completed successfully the task.\nEx.\n{``cmd1``: [``device1``, " + "``device2``], ``cmd2``: [``device2``, ``device3``]}", ) """Device attribute.""" @@ -309,13 +313,13 @@ class CspSubElementSubarray(SKASubarray): def read_scanID(self): # PROTECTED REGION ID(CspSubElementSubarray.scanID_read) ENABLED START # """Return the scanID attribute.""" - return self.component_manager.scan_id # pylint: disable=no-member + return self.component_manager.scan_id # PROTECTED REGION END # // CspSubElementSubarray.scanID_read def read_configurationID(self): # PROTECTED REGION ID(CspSubElementSubarray.configurationID_read) ENABLED START # """Return the configurationID attribute.""" - return self.component_manager.config_id # pylint: disable=no-member + return self.component_manager.config_id # PROTECTED REGION END # // CspSubElementSubarray.configurationID_read def read_sdpDestinationAddresses(self): diff --git a/src/ska_tango_base/obs/obs_device.py b/src/ska_tango_base/obs/obs_device.py index d9bef7ee..d993a9dc 100644 --- a/src/ska_tango_base/obs/obs_device.py +++ b/src/ska_tango_base/obs/obs_device.py @@ -13,8 +13,6 @@ instead of just SKABaseDevice. # Additional import # PROTECTED REGION ID(SKAObsDevice.additionnal_import) ENABLED START # -import warnings - # Tango imports from tango.server import run, attribute diff --git a/src/ska_tango_base/subarray/reference_component_manager.py b/src/ska_tango_base/subarray/reference_component_manager.py index dd7436ee..6ca16084 100644 --- a/src/ska_tango_base/subarray/reference_component_manager.py +++ b/src/ska_tango_base/subarray/reference_component_manager.py @@ -3,8 +3,6 @@ This module models component management for SKA subarray devices. """ import functools -from tango import DevState - from ska_tango_base.subarray import SubarrayComponentManager from ska_tango_base.base import ( check_communicating, diff --git a/src/ska_tango_base/subarray/subarray_device.py b/src/ska_tango_base/subarray/subarray_device.py index 6b4d9530..61e5a125 100644 --- a/src/ska_tango_base/subarray/subarray_device.py +++ b/src/ska_tango_base/subarray/subarray_device.py @@ -12,7 +12,6 @@ information like assigned resources, configured capabilities, etc. """ # PROTECTED REGION ID(SKASubarray.additionnal_import) ENABLED START # import json -import warnings from tango import DebugIt from tango.server import run, attribute, command @@ -295,7 +294,7 @@ class SKASubarray(SKAObsDevice): component_manager = self.target component_manager.scan(argin) - message = f"Scan command started" + message = "Scan command started" self.logger.info(message) return (ResultCode.STARTED, message) @@ -639,7 +638,7 @@ class SKASubarray(SKAObsDevice): :return: Resources assigned to the device. """ - return self.component_manager.assigned_resources # pylint: disable=no-member + return self.component_manager.assigned_resources # PROTECTED REGION END # // SKASubarray.assignedResources_read def read_configuredCapabilities(self): @@ -650,9 +649,7 @@ class SKASubarray(SKAObsDevice): :return: A list of capability types with no. of instances used in the Subarray """ - return ( - self.component_manager.configured_capabilities # pylint: disable=no-member - ) + return self.component_manager.configured_capabilities # PROTECTED REGION END # // SKASubarray.configuredCapabilities_read # -------- diff --git a/src/ska_tango_base/subarray/subarray_obs_state_model.py b/src/ska_tango_base/subarray/subarray_obs_state_model.py index 5562a676..76de3042 100644 --- a/src/ska_tango_base/subarray/subarray_obs_state_model.py +++ b/src/ska_tango_base/subarray/subarray_obs_state_model.py @@ -7,7 +7,7 @@ subarray Tango devices. It consists of: * an :py:class:`.SubarrayObsStateModel` that maps the underlying state machine state to a value of the :py:class:`ska_tango_base.control_model.ObsState` enum. - + """ from transitions.extensions import LockedMachine as Machine diff --git a/tests/conftest.py b/tests/conftest.py index 84108f5b..5dfbbd92 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,6 @@ """ A module defining a list of fixtures that are shared across all ska_tango_base tests. """ -import importlib import logging from queue import Empty, Queue diff --git a/tests/test_alarm_handler_device.py b/tests/test_alarm_handler_device.py index af8366d4..8aaffda8 100644 --- a/tests/test_alarm_handler_device.py +++ b/tests/test_alarm_handler_device.py @@ -17,12 +17,15 @@ from ska_tango_base import SKAAlarmHandler from ska_tango_base.base import ReferenceBaseComponentManager from ska_tango_base.control_model import AdminMode + # PROTECTED REGION ID(SKAAlarmHandler.test_additional_imports) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_additional_imports # Device test case # PROTECTED REGION ID(SKAAlarmHandler.test_SKAAlarmHandler_decorators) ENABLED START # -@pytest.mark.usefixtures("tango_context", "initialize_device") # PROTECTED REGION END # // SKAAlarmHandler.test_SKAAlarmHandler_decorators + + +@pytest.mark.usefixtures("tango_context", "initialize_device") class TestSKAAlarmHandler(object): """ Test class for tests of the SKAAlarmHander device class. diff --git a/tests/test_csp_subarray.py b/tests/test_csp_subarray.py index f9fc4583..22cffd03 100644 --- a/tests/test_csp_subarray.py +++ b/tests/test_csp_subarray.py @@ -294,7 +294,7 @@ class TestCspSubElementSubarray(object): def test_configureScanTimeoutExpiredFlag(self, tango_context): """Test for timeoutExpiredFlag""" # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag) ENABLED START # - assert tango_context.device.configureScanTimeoutExpiredFlag == False + assert not tango_context.device.configureScanTimeoutExpiredFlag # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag_decorators) ENABLED START # @@ -302,7 +302,7 @@ class TestCspSubElementSubarray(object): def test_assignResourcesTimeoutExpiredFlag(self, tango_context): """Test for timeoutExpiredFlag""" # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag) ENABLED START # - assert tango_context.device.assignResourcesTimeoutExpiredFlag == False + assert not tango_context.device.assignResourcesTimeoutExpiredFlag # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag_decorators) ENABLED START # @@ -310,7 +310,7 @@ class TestCspSubElementSubarray(object): def test_releaseResourcesTimeoutExpiredFlag(self, tango_context): """Test for timeoutExpiredFlag""" # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag) ENABLED START # - assert tango_context.device.releaseResourcesTimeoutExpiredFlag == False + assert not tango_context.device.releaseResourcesTimeoutExpiredFlag # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_decorators) ENABLED START # -- GitLab