diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml index 8c6b0bbe..215b5285 100644 --- a/spiffworkflow-backend/pyproject.toml +++ b/spiffworkflow-backend/pyproject.toml @@ -211,6 +211,12 @@ exclude = [ [tool.ruff.isort] force-single-line = true +# pip install fixit && fixit fix -a src +[tool.fixit] +disable = [ + "fixit.rules:CompareSingletonPrimitivesByIs", +] + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/exceptions/api_error.py b/spiffworkflow-backend/src/spiffworkflow_backend/exceptions/api_error.py index 485471f8..c610c808 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/exceptions/api_error.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/exceptions/api_error.py @@ -64,7 +64,7 @@ class ApiError(Exception): if self.line_number: msg += "Error is on line %i. " % self.line_number if self.file_name: - msg += "In file %s. " % self.file_name + msg += f"In file {self.file_name}. " return msg @classmethod @@ -288,11 +288,7 @@ def handle_exception(exception: Exception) -> flask.wrappers.Response: error_code = "internal_server_error" status_code = 500 - if ( - isinstance(exception, NotAuthorizedError) - or isinstance(exception, TokenNotProvidedError) - or isinstance(exception, TokenInvalidError) - ): + if isinstance(exception, NotAuthorizedError | TokenNotProvidedError | TokenInvalidError): error_code = "not_authorized" status_code = 403 if isinstance(exception, UserNotLoggedInError): diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py index dc058796..f9d09548 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py @@ -131,6 +131,6 @@ class ProcessInstanceReportModel(SpiffworkflowBaseDBModel): def with_substitutions(self, field_value: Any, substitution_variables: dict) -> Any: if substitution_variables is not None: for key, value in substitution_variables.items(): - if isinstance(value, str) or isinstance(value, int): + if isinstance(value, str | int): field_value = str(field_value).replace("{{" + key + "}}", str(value)) return field_value diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_all_permissions.py b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_all_permissions.py index 0721fd97..3fde9037 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_all_permissions.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_all_permissions.py @@ -47,7 +47,7 @@ class GetAllPermissions(Script): # sort list of strings based on a specific order def sort_by_order(string_list: list, order: list) -> list: - return sorted(string_list, key=lambda x: order.index(x)) + return sorted(string_list, key=order.index) return [ { diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/script.py b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/script.py index 777f3ef0..dac349e3 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/script.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/script.py @@ -51,7 +51,7 @@ class Script: ) -> Any: raise ApiError( "invalid_script", - "This is an internal error. The script you are trying to execute '%s' " % self.__class__.__name__ + f"This is an internal error. The script you are trying to execute '{self.__class__.__name__}' " + "does not properly implement the run function.", ) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py index 83221d5e..455bef33 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/git_service.py @@ -179,7 +179,7 @@ class GitService: ssh_key_path = current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH") if ssh_key_path is not None: my_env["GIT_SSH_COMMAND"] = ( - "ssh -F /dev/null -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s" % ssh_key_path + f"ssh -F /dev/null -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {ssh_key_path}" ) command_to_run = command diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index b42d9eef..fe5ff28b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -1283,8 +1283,10 @@ class ProcessInstanceProcessor: raise ( ApiError( error_code="could_not_find_bpmn_process_identifier", - message="Could not find the the given bpmn process identifier from any sources: %s" - % bpmn_process_identifier, + message=( + "Could not find the the given bpmn process identifier from any sources:" + f" {bpmn_process_identifier}" + ), ) ) return os.path.abspath(bpmn_file_full_path) @@ -1353,7 +1355,7 @@ class ProcessInstanceProcessor: raise ( ApiError( error_code="no_primary_bpmn_error", - message="There is no primary BPMN process id defined for process_model %s" % process_model_info.id, + message=f"There is no primary BPMN process id defined for process_model {process_model_info.id}", ) ) ProcessInstanceProcessor.update_spiff_parser_with_all_process_dependency_files(parser) @@ -1366,7 +1368,7 @@ class ProcessInstanceProcessor: except ValidationException as ve: raise ApiError( error_code="process_instance_validation_error", - message="Failed to parse the Workflow Specification. " + "Error is '%s.'" % str(ve), + message="Failed to parse the Workflow Specification. " + f"Error is '{str(ve)}.'", file_name=ve.file_name, task_name=ve.name, task_id=ve.id, diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py index dc3a35a7..ca433515 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py @@ -345,7 +345,7 @@ class ProcessInstanceService: else: raise ApiError.from_task( error_code="task_lane_user_error", - message="Spiff Task %s lane user is not a string or dict" % spiff_task.task_spec.name, + message=f"Spiff Task {spiff_task.task_spec.name} lane user is not a string or dict", task=spiff_task, )