Bläddra i källkod

Avoid flake8 false positives around f strings

Recent flake8 versions cannot handle f strings properly, treating
the string contents as Python code.

We'll add "noqa" comments where applicable.
Lucian Petrut 1 månad sedan
förälder
incheckning
4c8c4a3fb1

+ 4 - 4
coriolis/api/v1/transfers.py

@@ -70,8 +70,8 @@ class TransferController(api_wsgi.Controller):
             if scenario not in SUPPORTED_TRANSFER_SCENARIOS:
                 raise exc.HTTPBadRequest(
                     explanation=f"Unsupported Transfer creation scenario "
-                                f"'{scenario}', must be one of: "
-                                f"{SUPPORTED_TRANSFER_SCENARIOS}")
+                                f"'{scenario}', must be one of: "  # noqa
+                                f"{SUPPORTED_TRANSFER_SCENARIOS}")  # noqa
         else:
             scenario = constants.TRANSFER_SCENARIO_REPLICA
             LOG.warn(
@@ -317,8 +317,8 @@ class TransferController(api_wsgi.Controller):
         if scenario and scenario != transfer["scenario"]:
             raise exc.HTTPBadRequest(
                 explanation=f"Changing Transfer creation scenario is not "
-                            f"supported (original scenario is "
-                            f"{transfer['scenario']}, received '{scenario}')")
+                            f"supported (original scenario is "  # noqa
+                            f"{transfer['scenario']}, received '{scenario}')")  # noqa
 
         transfer_body = body['transfer']
         origin_endpoint_id = transfer_body.get('origin_endpoint_id', None)

+ 2 - 2
coriolis/conductor/rpc/server.py

@@ -302,7 +302,7 @@ class ConductorServerEndpoint(object):
         if not reservation_type:
             raise exception.LicensingException(
                 message="Could not determine reservation type for transfer "
-                        f"'{action_id}' with scenario '{transfer.scenario}'.")
+                        f"'{action_id}' with scenario '{transfer.scenario}'.")  # noqa
         if not self._licensing_client:
             LOG.warn(
                 "Licensing client not instantiated. Skipping creation of "
@@ -1300,7 +1300,7 @@ class ConductorServerEndpoint(object):
         if transfer_scenario not in supported_scenarios:
             raise exception.InvalidInput(
                 message=f"Unsupported Transfer scenario '{transfer_scenario}'."
-                        f" Must be one of: {supported_scenarios}")
+                        f" Must be one of: {supported_scenarios}")  # noqa
 
         origin_endpoint = self.get_endpoint(ctxt, origin_endpoint_id)
         destination_endpoint = self.get_endpoint(

+ 2 - 2
coriolis/db/api.py

@@ -902,7 +902,7 @@ def add_task_progress_update(
             f"Progress message for task '{task_id}' with ID '{task_event_id}'"
             f"is too long. Truncating before insertion. "
             f"Original message was: '{message}'")
-        message = f"{message[:max_msg_len-len('...')]}..."
+        message = f"{message[:max_msg_len-len('...')]}..."  # noqa
     task_progress_update.message = message
 
     task_progress_update.index = 0
@@ -936,7 +936,7 @@ def update_task_progress_update(
                 f"Progress message for task '{task_id}' with ID "
                 f"'{task_event_id}' is too long. Truncating before insertion."
                 f" Original message was: '{new_message}'")
-            new_message = f"{new_message[:max_msg_len-len('...')]}..."
+            new_message = f"{new_message[:max_msg_len-len('...')]}..."  # noqa
         task_progress_update.message = new_message
 
 

+ 3 - 3
coriolis/osmorphing/windows.py

@@ -341,7 +341,7 @@ class BaseWindowsMorphingTools(base.BaseOSMorphingTools):
             @({paths_string}) | ForEach-Object {{
                 Set-ItemProperty -Path $_ -Name 'Start' -Value {start_mode}
             }}
-            """,
+            """,  # noqa
             ignore_stdout=True)
 
     def _create_service(self, key_name, service_name, image_path,
@@ -667,8 +667,8 @@ class BaseWindowsMorphingTools(base.BaseOSMorphingTools):
             if diff:
                 LOG.warning(
                     f"The IP addresses {list(diff)} found on the source "
-                    f"VM's NIC were not found in the registry. These IPs will "
-                    f"be skipped in the static IP configuration process")
+                    "VM's NIC were not found in the registry. These IPs will "
+                    "be skipped in the static IP configuration process")
                 ip_matches = list(
                     set(reg_ip_addresses).intersection(set(nic_ips)))
                 if not ip_matches:

+ 1 - 1
coriolis/tests/api/v1/test_endpoint_destination_options.py

@@ -48,7 +48,7 @@ class EndpointDestinationOptionsControllerTestCase(
 
         mock_context.can.assert_called_once_with(
             'migration:endpoints:list_destination_options')
-        mock_decode_base64_param.has_calls(expected_calls)
+        mock_decode_base64_param.assert_has_calls(expected_calls)
         mock_get_endpoint_destination_options.assert_called_once_with(
             mock_context, endpoint_id,
             env=env,