From b63693514a89de165ab81d28a6acbf45d7f8780a Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 15 Nov 2022 10:28:18 -0500 Subject: [PATCH] fix mypy typing stuff. w/ jasquat --- .../src/spiffworkflow_backend/models/spec_reference.py | 6 +++--- .../routes/process_api_blueprint.py | 9 ++++++--- .../spiffworkflow_backend/services/spec_file_service.py | 7 ------- .../integration/test_process_api.py | 9 ++++----- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py index 810cbc440..3c3848993 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py @@ -3,7 +3,7 @@ from dataclasses import dataclass from flask_bpmn.models.db import db from flask_bpmn.models.db import SpiffworkflowBaseDBModel -from flask_marshmallow import Schema +from flask_marshmallow import Schema # type: ignore from marshmallow import INCLUDE @@ -48,7 +48,7 @@ class SpecReferenceCache(SpiffworkflowBaseDBModel): is_primary = db.Column(db.Boolean()) @classmethod - def from_spec_reference(cls, ref): + def from_spec_reference(cls, ref: SpecReference) -> "SpecReferenceCache": """From_spec_reference.""" return cls( identifier=ref.identifier, @@ -63,7 +63,7 @@ class SpecReferenceCache(SpiffworkflowBaseDBModel): ) -class SpecReferenceSchema(Schema): +class SpecReferenceSchema(Schema): # type: ignore """FileSchema.""" class Meta: diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index e61d00794..1722635cf 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -339,9 +339,12 @@ def process_model_list( return Response(json.dumps(response_json), status=200, mimetype="application/json") -def process_list() -> any: - """Returns a list of all known processes - this includes processes that are not the - primary process - helpful for finding possible call activities.""" +def process_list() -> Any: + """Returns a list of all known processes. + + This includes processes that are not the + primary process - helpful for finding possible call activities. + """ references = SpecReferenceCache.query.filter_by(type="process") return SpecReferenceSchema(many=True).dump(references) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py index e8e334f21..8b629de99 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py @@ -61,13 +61,6 @@ class SpecFileService(FileSystemService): ref_map[ref.identifier] = ref return ref_map - @staticmethod - def get_references(process_models: List[ProcessModelInfo]) -> list[SpecReference]: - """Returns all references -- process_ids, and decision ids, across all process models provided.""" - references = [] - for process_model in process_models: - references.extend(SpecFileService.get_references_for_process(process_model)) - @staticmethod def get_references_for_process( process_model_info: ProcessModelInfo, diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py index b02f1eb08..85ee4a058 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_process_api.py @@ -446,9 +446,8 @@ class TestProcessApi(BaseTest): client: FlaskClient, with_db_and_bpmn_file_cleanup: None, with_super_admin_user: UserModel, - ): + ) -> None: """It should be possible to get a list of all processes known to the system.""" - load_test_spec( "test_group_one/simple_form", process_model_source_directory="simple_form", @@ -480,9 +479,9 @@ class TestProcessApi(BaseTest): ) assert simple_form["display_name"] == "Process With Form" assert simple_form["process_model_id"] == "test_group_one/simple_form" - assert simple_form["has_lanes"] == False - assert simple_form["is_executable"] == True - assert simple_form["is_primary"] == True + assert simple_form["has_lanes"] is False + assert simple_form["is_executable"] is True + assert simple_form["is_primary"] is True def test_process_group_add( self,