From cf40546a096908bbd3598cea8bfa95e126195f31 Mon Sep 17 00:00:00 2001 From: burnettk Date: Fri, 26 May 2023 13:07:18 -0400 Subject: [PATCH] get compatible with default ruff ruleset --- spiffworkflow-backend/pyproject.toml | 6 ++++++ .../src/spiffworkflow_backend/load_database_models.py | 2 ++ .../spiffworkflow_backend/scripts/get_encoded_file_data.py | 2 +- .../scripts/markdown_file_download_link.py | 2 +- .../src/spiffworkflow_backend/services/logging_service.py | 2 +- .../services/process_instance_processor.py | 6 ++++-- .../unit/test_process_instance_service.py | 2 +- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml index d3d152fe..1dc1b4a4 100644 --- a/spiffworkflow-backend/pyproject.toml +++ b/spiffworkflow-backend/pyproject.toml @@ -170,6 +170,12 @@ implicit_reexport = true namespace_packages = true explicit_package_bases = false +[tool.ruff] +line-length = 130 + +[tool.ruff.per-file-ignores] +"migrations/versions/*.py" = ["E501"] + [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py b/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py index 8b9a6322..06d4c365 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py @@ -7,6 +7,8 @@ some models need to be loaded before others for relationships and to avoid circular imports """ +# unused imports are needed for SQLAlchemy to load the models +# ruff: noqa: F401 from spiffworkflow_backend.models.db import add_listeners diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_encoded_file_data.py b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_encoded_file_data.py index 9cc442b3..106510a0 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_encoded_file_data.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/get_encoded_file_data.py @@ -31,7 +31,7 @@ class GetEncodedFileData(Script): ) -> Any: """Run.""" # example input: - # "data:some/mimetype;name=testing.txt;base64,spifffiledatadigest+7a2051ffefd1eaf475dbef9fda019cb3d4a10eb8aea4c2c2a84a50a797a541bf" + # "data:some/mimetype;name=testing.txt;base64,spifffiledatadigest+7a2051ffefd1eaf475dbef9fda019cb3d4a10eb8aea4c2c2a84a50a797a541bf" # noqa: B950,E501 digest_reference = args[0] digest = digest_reference[-64:] process_instance_id = script_attributes_context.process_instance_id diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/markdown_file_download_link.py b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/markdown_file_download_link.py index a7a9d3b0..f5bd276f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/scripts/markdown_file_download_link.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/scripts/markdown_file_download_link.py @@ -30,7 +30,7 @@ class GetMarkdownFileDownloadLink(Script): ) -> Any: """Run.""" # example input: - # "data:some/mimetype;name=testing.txt;base64,spifffiledatadigest+7a2051ffefd1eaf475dbef9fda019cb3d4a10eb8aea4c2c2a84a50a797a541bf" + # "data:some/mimetype;name=testing.txt;base64,spifffiledatadigest+7a2051ffefd1eaf475dbef9fda019cb3d4a10eb8aea4c2c2a84a50a797a541bf" # noqa: B950,E501 digest_reference = args[0] parts = digest_reference.split(";") digest = parts[2].split(",")[1][-64:] diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py index 82b858be..a5fa9857 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/logging_service.py @@ -18,7 +18,7 @@ from flask.app import Flask # %(message)s—The log message. # full message list: -# {'name': 'gunicorn.error', 'msg': 'GET /admin/token', 'args': (), 'levelname': 'DEBUG', 'levelno': 10, 'pathname': '~/.cache/pypoetry/virtualenvs/spiffworkflow-backend-R_hdWfN1-py3.10/lib/python3.10/site-packages/gunicorn/glogging.py', 'filename': 'glogging.py', 'module': 'glogging', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 267, 'funcName': 'debug', 'created': 1657307111.4513023, 'msecs': 451.30228996276855, 'relativeCreated': 1730.785846710205, 'thread': 139945864087360, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 2109561, 'message': 'GET /admin/token', 'asctime': '2022-07-08T15:05:11.451Z'} +# {'name': 'gunicorn.error', 'msg': 'GET /admin/token', 'args': (), 'levelname': 'DEBUG', 'levelno': 10, 'pathname': '~/.cache/pypoetry/virtualenvs/spiffworkflow-backend-R_hdWfN1-py3.10/lib/python3.10/site-packages/gunicorn/glogging.py', 'filename': 'glogging.py', 'module': 'glogging', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 267, 'funcName': 'debug', 'created': 1657307111.4513023, 'msecs': 451.30228996276855, 'relativeCreated': 1730.785846710205, 'thread': 139945864087360, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 2109561, 'message': 'GET /admin/token', 'asctime': '2022-07-08T15:05:11.451Z'} # noqa: E501 class InvalidLogLevelError(Exception): 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 d713af7d..d9cfa0ee 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -1689,8 +1689,10 @@ class ProcessInstanceProcessor: ) task_service.update_all_tasks_from_spiff_tasks(spiff_tasks, deleted_tasks, start_time) - # we may want to move this to task_service.update_all_tasks_from_spiff_tasks but not sure it's always good to it. - # for cancelled tasks, spiff only returns tasks that were cancelled, not the ones that were deleted so we have to find them + # we may want to move this to task_service.update_all_tasks_from_spiff_tasks, + # but not sure it's always good to it. + # for cancelled tasks, spiff only returns tasks that were cancelled, + # not the ones that were deleted so we have to find them spiff_task_guids = [str(st.id) for st in spiff_tasks] tasks_no_longer_in_spiff = TaskModel.query.filter( and_( diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py index 274245e5..a566f1c4 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py @@ -18,7 +18,7 @@ class TestProcessInstanceService(BaseTest): """TestProcessInstanceService.""" SAMPLE_FILE_DATA = "data:some/mimetype;name=testing.txt;base64,dGVzdGluZwo=" - SAMPLE_DIGEST_REFERENCE = f"data:some/mimetype;name=testing.txt;base64,{ProcessInstanceService.FILE_DATA_DIGEST_PREFIX}12a61f4e173fb3a11c05d6471f74728f76231b4a5fcd9667cef3af87a3ae4dc2" # noqa: B950 + SAMPLE_DIGEST_REFERENCE = f"data:some/mimetype;name=testing.txt;base64,{ProcessInstanceService.FILE_DATA_DIGEST_PREFIX}12a61f4e173fb3a11c05d6471f74728f76231b4a5fcd9667cef3af87a3ae4dc2" # noqa: B950,E501 def _check_sample_file_data_model( self,