Repository: XKNX/xknx
Pull request #429 (2020-09-25 22:01:59)

readd logging-not-lazy check


Patch:
diff --git a/.pylintrc b/.pylintrc
index 6e22a9ee..deac14bc 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -43,9 +43,7 @@ disable=
   too-many-statements,
   too-many-boolean-expressions,
   unused-argument,
-  wrong-import-order,
-  logging-not-lazy,
-  logging-fstring-interpolation
+  wrong-import-order
 # enable useless-suppression temporarily every now and then to clean them up
 enable=
   use-symbolic-message-instead
diff --git a/xknx/core/state_updater.py b/xknx/core/state_updater.py
index 6b7af52d..bb2ccbaf 100644
--- a/xknx/core/state_updater.py
+++ b/xknx/core/state_updater.py
@@ -45,8 +45,11 @@ class StateUpdater:
                     tracker_type = StateTrackerType.PERIODICALLY
                 else:
                     logger.warning(
-                        'Could not parse StateUpdater tracker_options "%s" for %s. Using default %s %s minutes.'
-                        % (tracker_options, remote_value, tracker_type, update_interval)
+                        'Could not parse StateUpdater tracker_options "%s" for %s. Using default %s %s minutes.',
+                        tracker_options,
+                        remote_value,
+                        tracker_type,
+                        update_interval,
                     )
                     return (tracker_type, update_interval)
                 try:
@@ -56,14 +59,12 @@ class StateUpdater:
                     pass  # No time given (no _options[1])
             else:
                 logger.warning(
-                    'Could not parse StateUpdater tracker_options type %s "%s" for %s. Using default %s %s minutes.'
-                    % (
-                        type(tracker_options),
-                        tracker_options,
-                        remote_value,
-                        tracker_type,
-                        update_interval,
-                    )
+                    'Could not parse StateUpdater tracker_options type %s "%s" for %s. Using default %s %s minutes.',
+                    type(tracker_options),
+                    tracker_options,
+                    remote_value,
+                    tracker_type,
+                    update_interval,
                 )
             return (tracker_type, update_interval)
 
@@ -80,7 +81,10 @@ class StateUpdater:
         self._workers[id(remote_value)] = tracker
 
         logger.debug(
-            f"StateUpdater registered {tracker_type} {update_inteval} for {remote_value}"
+            "StateUpdater registered %s %s for %s",
+            tracker_type,
+            update_inteval,
+            remote_value,
         )
         if self.started:
             tracker.start()
@@ -152,8 +156,10 @@ class _StateTracker:
     def start(self):
         """Start StateTracker - read state on call."""
         logger.debug(
-            "StateUpdater initializing %s for %s - %s"
-            % (self.group_address, self.device_name, self.feature_name)
+            "StateUpdater initializing %s for %s - %s",
+            self.group_address,
+            self.device_name,
+            self.feature_name,
         )
         if self.tracker_type is not StateTrackerType.INIT:
             self._start_waiting()
@@ -193,7 +199,9 @@ class _StateTracker:
     def _read_state(self):
         """Schedule to read the state from the KNX bus."""
         logger.debug(
-            "StateUpdater scheduled reading %s for %s - %s"
-            % (self.group_address, self.device_name, self.feature_name)
+            "StateUpdater scheduled reading %s for %s - %s",
+            self.group_address,
+            self.device_name,
+            self.feature_name,
         )
         self.xknx.loop.create_task(self._read_state_awaitable())


Test patch:
diff --git a/test/core_tests/state_updater_test.py b/test/core_tests/state_updater_test.py
index c8d5372a..45ccf1a9 100644
--- a/test/core_tests/state_updater_test.py
+++ b/test/core_tests/state_updater_test.py
@@ -117,8 +117,11 @@ class TestStateUpdater(unittest.TestCase):
             xknx, sync_state="invalid", group_address_state=GroupAddress("1/1/1")
         )
         logging_warning_mock.assert_called_once_with(
-            'Could not parse StateUpdater tracker_options "invalid" for %s. '
-            "Using default StateTrackerType.EXPIRE 60 minutes." % remote_value_invalid
+            'Could not parse StateUpdater tracker_options "%s" for %s. Using default %s %s minutes.',
+            "invalid",
+            remote_value_invalid,
+            StateTrackerType.EXPIRE,
+            60,
         )
         self.assertEqual(_get_only_tracker().tracker_type, StateTrackerType.EXPIRE)
         self.assertEqual(_get_only_tracker().update_interval, 60 * 60)
@@ -129,8 +132,12 @@ class TestStateUpdater(unittest.TestCase):
             xknx, sync_state=5.6, group_address_state=GroupAddress("1/1/1")
         )
         logging_warning_mock.assert_called_once_with(
-            "Could not parse StateUpdater tracker_options type <class 'float'> \"5.6\" for %s. "
-            "Using default StateTrackerType.EXPIRE 60 minutes." % remote_value_float
+            'Could not parse StateUpdater tracker_options type %s "%s" for %s. Using default %s %s minutes.',
+            float,
+            5.6,
+            remote_value_float,
+            StateTrackerType.EXPIRE,
+            60,
         )
         self.assertEqual(_get_only_tracker().tracker_type, StateTrackerType.EXPIRE)
         self.assertEqual(_get_only_tracker().update_interval, 60 * 60)