fixes from fixit 2
This commit is contained in:
parent
b031b0f940
commit
f524b78368
|
@ -211,6 +211,12 @@ exclude = [
|
||||||
[tool.ruff.isort]
|
[tool.ruff.isort]
|
||||||
force-single-line = true
|
force-single-line = true
|
||||||
|
|
||||||
|
# pip install fixit && fixit fix -a src
|
||||||
|
[tool.fixit]
|
||||||
|
disable = [
|
||||||
|
"fixit.rules:CompareSingletonPrimitivesByIs",
|
||||||
|
]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
|
@ -64,7 +64,7 @@ class ApiError(Exception):
|
||||||
if self.line_number:
|
if self.line_number:
|
||||||
msg += "Error is on line %i. " % self.line_number
|
msg += "Error is on line %i. " % self.line_number
|
||||||
if self.file_name:
|
if self.file_name:
|
||||||
msg += "In file %s. " % self.file_name
|
msg += f"In file {self.file_name}. "
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -288,11 +288,7 @@ def handle_exception(exception: Exception) -> flask.wrappers.Response:
|
||||||
|
|
||||||
error_code = "internal_server_error"
|
error_code = "internal_server_error"
|
||||||
status_code = 500
|
status_code = 500
|
||||||
if (
|
if isinstance(exception, NotAuthorizedError | TokenNotProvidedError | TokenInvalidError):
|
||||||
isinstance(exception, NotAuthorizedError)
|
|
||||||
or isinstance(exception, TokenNotProvidedError)
|
|
||||||
or isinstance(exception, TokenInvalidError)
|
|
||||||
):
|
|
||||||
error_code = "not_authorized"
|
error_code = "not_authorized"
|
||||||
status_code = 403
|
status_code = 403
|
||||||
if isinstance(exception, UserNotLoggedInError):
|
if isinstance(exception, UserNotLoggedInError):
|
||||||
|
|
|
@ -131,6 +131,6 @@ class ProcessInstanceReportModel(SpiffworkflowBaseDBModel):
|
||||||
def with_substitutions(self, field_value: Any, substitution_variables: dict) -> Any:
|
def with_substitutions(self, field_value: Any, substitution_variables: dict) -> Any:
|
||||||
if substitution_variables is not None:
|
if substitution_variables is not None:
|
||||||
for key, value in substitution_variables.items():
|
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))
|
field_value = str(field_value).replace("{{" + key + "}}", str(value))
|
||||||
return field_value
|
return field_value
|
||||||
|
|
|
@ -47,7 +47,7 @@ class GetAllPermissions(Script):
|
||||||
|
|
||||||
# sort list of strings based on a specific order
|
# sort list of strings based on a specific order
|
||||||
def sort_by_order(string_list: list, order: list) -> list:
|
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 [
|
return [
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Script:
|
||||||
) -> Any:
|
) -> Any:
|
||||||
raise ApiError(
|
raise ApiError(
|
||||||
"invalid_script",
|
"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.",
|
+ "does not properly implement the run function.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ class GitService:
|
||||||
ssh_key_path = current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH")
|
ssh_key_path = current_app.config.get("SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH")
|
||||||
if ssh_key_path is not None:
|
if ssh_key_path is not None:
|
||||||
my_env["GIT_SSH_COMMAND"] = (
|
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
|
command_to_run = command
|
||||||
|
|
|
@ -1283,8 +1283,10 @@ class ProcessInstanceProcessor:
|
||||||
raise (
|
raise (
|
||||||
ApiError(
|
ApiError(
|
||||||
error_code="could_not_find_bpmn_process_identifier",
|
error_code="could_not_find_bpmn_process_identifier",
|
||||||
message="Could not find the the given bpmn process identifier from any sources: %s"
|
message=(
|
||||||
% bpmn_process_identifier,
|
"Could not find the the given bpmn process identifier from any sources:"
|
||||||
|
f" {bpmn_process_identifier}"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return os.path.abspath(bpmn_file_full_path)
|
return os.path.abspath(bpmn_file_full_path)
|
||||||
|
@ -1353,7 +1355,7 @@ class ProcessInstanceProcessor:
|
||||||
raise (
|
raise (
|
||||||
ApiError(
|
ApiError(
|
||||||
error_code="no_primary_bpmn_error",
|
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)
|
ProcessInstanceProcessor.update_spiff_parser_with_all_process_dependency_files(parser)
|
||||||
|
@ -1366,7 +1368,7 @@ class ProcessInstanceProcessor:
|
||||||
except ValidationException as ve:
|
except ValidationException as ve:
|
||||||
raise ApiError(
|
raise ApiError(
|
||||||
error_code="process_instance_validation_error",
|
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,
|
file_name=ve.file_name,
|
||||||
task_name=ve.name,
|
task_name=ve.name,
|
||||||
task_id=ve.id,
|
task_id=ve.id,
|
||||||
|
|
|
@ -345,7 +345,7 @@ class ProcessInstanceService:
|
||||||
else:
|
else:
|
||||||
raise ApiError.from_task(
|
raise ApiError.from_task(
|
||||||
error_code="task_lane_user_error",
|
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,
|
task=spiff_task,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue