diff --git a/alembic/versions/0defbfc71c59_add_identifier_to_version.py b/alembic/versions/0defbfc71c59_add_identifier_to_version.py index 8adc24e0..128cca30 100644 --- a/alembic/versions/0defbfc71c59_add_identifier_to_version.py +++ b/alembic/versions/0defbfc71c59_add_identifier_to_version.py @@ -5,6 +5,7 @@ Create Date: 2024-01-05 13:25:15.547450 """ + from typing import Sequence, Union from alembic import op diff --git a/alembic/versions/29e42ce4be3f_adding_license_text.py b/alembic/versions/29e42ce4be3f_adding_license_text.py index f00ead96..190db9d2 100644 --- a/alembic/versions/29e42ce4be3f_adding_license_text.py +++ b/alembic/versions/29e42ce4be3f_adding_license_text.py @@ -5,6 +5,7 @@ Create Date: 2023-12-21 13:34:26.478808 """ + from typing import Sequence, Union from alembic import op diff --git a/alembic/versions/31703d707dfb_contributor_name_change.py b/alembic/versions/31703d707dfb_contributor_name_change.py index 0804cf43..60fa9d5f 100644 --- a/alembic/versions/31703d707dfb_contributor_name_change.py +++ b/alembic/versions/31703d707dfb_contributor_name_change.py @@ -5,6 +5,7 @@ Create Date: 2024-02-20 08:25:11.511833 """ + from typing import Sequence, Union from alembic import op @@ -12,15 +13,17 @@ # revision identifiers, used by Alembic. -revision: str = '31703d707dfb' -down_revision: Union[str, None] = '0defbfc71c59' +revision: str = "31703d707dfb" +down_revision: Union[str, None] = "0defbfc71c59" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.drop_column("dataset_contributor", "name") - op.add_column("dataset_contributor", sa.Column("family_name", sa.String, nullable=True)) + op.add_column( + "dataset_contributor", sa.Column("family_name", sa.String, nullable=True) + ) op.add_column("dataset_contributor", sa.Column("given_name", sa.String)) op.execute("UPDATE dataset_contributor SET given_name = 'name'") with op.batch_alter_table("dataset_contributor") as batch_op: diff --git a/alembic/versions/72ac2b020c7c_delete_dataset_readme_table.py b/alembic/versions/72ac2b020c7c_delete_dataset_readme_table.py index f2ea30f3..5fac771b 100644 --- a/alembic/versions/72ac2b020c7c_delete_dataset_readme_table.py +++ b/alembic/versions/72ac2b020c7c_delete_dataset_readme_table.py @@ -5,6 +5,7 @@ Create Date: 2023-11-08 15:47:00.205940 """ + from typing import Sequence, Union import alembic diff --git a/apis/__init__.py b/apis/__init__.py index 3c48bc8a..1ce51ba3 100644 --- a/apis/__init__.py +++ b/apis/__init__.py @@ -1,4 +1,5 @@ """Initialize the api system for the backend""" + from flask_restx import Api, Resource from apis.dataset_metadata_namespace import api as dataset_metadata_namespace diff --git a/apis/authentication.py b/apis/authentication.py index 48eefe53..0d5a26c4 100644 --- a/apis/authentication.py +++ b/apis/authentication.py @@ -1,6 +1,7 @@ """This module is used to authenticate users to the system and handle few authentication errors. Also, it sets token for logged user along with expiration date""" + import datetime import importlib import os diff --git a/apis/dataset_metadata/dataset_alternate_identifier.py b/apis/dataset_metadata/dataset_alternate_identifier.py index 14a1c896..5d6b5e07 100644 --- a/apis/dataset_metadata/dataset_alternate_identifier.py +++ b/apis/dataset_metadata/dataset_alternate_identifier.py @@ -1,4 +1,5 @@ """API endpoints for dataset alternate identifier""" + from typing import Any, Union from flask import Response, request diff --git a/apis/dataset_metadata/dataset_consent.py b/apis/dataset_metadata/dataset_consent.py index a033273f..958822b2 100644 --- a/apis/dataset_metadata/dataset_consent.py +++ b/apis/dataset_metadata/dataset_consent.py @@ -1,4 +1,5 @@ """API for dataset consent metadata""" + from flask import request from flask_restx import Resource, fields from jsonschema import ValidationError, validate diff --git a/apis/dataset_metadata/dataset_contributor.py b/apis/dataset_metadata/dataset_contributor.py index d5510f7a..41336079 100644 --- a/apis/dataset_metadata/dataset_contributor.py +++ b/apis/dataset_metadata/dataset_contributor.py @@ -1,4 +1,5 @@ """API for dataset contributor metadata""" + from typing import Any, Union from flask import Response, request @@ -57,10 +58,7 @@ def post(self, study_id: int, dataset_id: int): "type": "string", "minLength": 1, }, - "family_name": { - "type": - ["string", "null"] - }, + "family_name": {"type": ["string", "null"]}, "name_identifier": { "type": "string", "minLength": 1, @@ -201,10 +199,7 @@ def post(self, study_id: int, dataset_id: int): "type": "string", "minLength": 1, }, - "family_name": { - "type": - ["string", "null"] - }, + "family_name": {"type": ["string", "null"]}, "name_identifier": { "type": "string", "minLength": 1, diff --git a/apis/dataset_metadata/dataset_date.py b/apis/dataset_metadata/dataset_date.py index 96eb4652..947c356d 100644 --- a/apis/dataset_metadata/dataset_date.py +++ b/apis/dataset_metadata/dataset_date.py @@ -1,4 +1,5 @@ """APIs for dataset date metadata""" + from typing import Any, Union from flask import Response, request diff --git a/apis/dataset_metadata/dataset_funder.py b/apis/dataset_metadata/dataset_funder.py index b6a3dece..7110e5b9 100644 --- a/apis/dataset_metadata/dataset_funder.py +++ b/apis/dataset_metadata/dataset_funder.py @@ -1,4 +1,5 @@ """API endpoints for dataset funder""" + from typing import Any, Union from flask import Response, request diff --git a/apis/dataset_metadata/dataset_other.py b/apis/dataset_metadata/dataset_other.py index 6df0f9aa..e00f9b86 100644 --- a/apis/dataset_metadata/dataset_other.py +++ b/apis/dataset_metadata/dataset_other.py @@ -1,4 +1,5 @@ """API endpoints for other dataset metadata""" + from flask import request from flask_restx import Resource, fields from jsonschema import ValidationError, validate diff --git a/apis/dataset_metadata/dataset_record_keys.py b/apis/dataset_metadata/dataset_record_keys.py index 8353463a..c4146022 100644 --- a/apis/dataset_metadata/dataset_record_keys.py +++ b/apis/dataset_metadata/dataset_record_keys.py @@ -1,4 +1,5 @@ """API endpoints for dataset record keys""" + from flask import request from flask_restx import Resource, fields from jsonschema import ValidationError, validate diff --git a/apis/dataset_metadata/dataset_related_item.py b/apis/dataset_metadata/dataset_related_item.py index cc526bf6..0a409b6a 100644 --- a/apis/dataset_metadata/dataset_related_item.py +++ b/apis/dataset_metadata/dataset_related_item.py @@ -1,4 +1,5 @@ """API for dataset related item""" + from typing import Any, Union from flask import Response, request diff --git a/apis/dataset_metadata/dataset_title.py b/apis/dataset_metadata/dataset_title.py index b22d02fa..b9da2382 100644 --- a/apis/dataset_metadata/dataset_title.py +++ b/apis/dataset_metadata/dataset_title.py @@ -1,4 +1,5 @@ """API for dataset title metadata""" + from typing import Any, Union from flask import Response, request diff --git a/apis/file.py b/apis/file.py index 4e8fc4e4..c2ad8d98 100644 --- a/apis/file.py +++ b/apis/file.py @@ -1,4 +1,5 @@ """APIs for study files""" + import importlib import os import uuid diff --git a/apis/study_metadata/study_arm.py b/apis/study_metadata/study_arm.py index fb37b2e8..1edf6e23 100644 --- a/apis/study_metadata/study_arm.py +++ b/apis/study_metadata/study_arm.py @@ -1,4 +1,5 @@ """API routes for study arm metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_available_ipd.py b/apis/study_metadata/study_available_ipd.py index 711e5280..7e12f5ba 100644 --- a/apis/study_metadata/study_available_ipd.py +++ b/apis/study_metadata/study_available_ipd.py @@ -1,4 +1,5 @@ """API routes for study available ipd metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_contact.py b/apis/study_metadata/study_contact.py index 4293d95c..8c02108c 100644 --- a/apis/study_metadata/study_contact.py +++ b/apis/study_metadata/study_contact.py @@ -1,4 +1,5 @@ """API routes for study contact metadata""" + import typing from email_validator import EmailNotValidError, validate_email diff --git a/apis/study_metadata/study_description.py b/apis/study_metadata/study_description.py index 026626e6..0c181dee 100644 --- a/apis/study_metadata/study_description.py +++ b/apis/study_metadata/study_description.py @@ -1,4 +1,5 @@ """API routes for study description metadata""" + from flask import request from flask_restx import Resource, fields from jsonschema import ValidationError, validate diff --git a/apis/study_metadata/study_design.py b/apis/study_metadata/study_design.py index 37cd77df..3d3cf0be 100644 --- a/apis/study_metadata/study_design.py +++ b/apis/study_metadata/study_design.py @@ -1,4 +1,5 @@ """API routes for study design metadata""" + import typing from flask import request diff --git a/apis/study_metadata/study_eligibility.py b/apis/study_metadata/study_eligibility.py index 7bd1771c..ee4d6af0 100644 --- a/apis/study_metadata/study_eligibility.py +++ b/apis/study_metadata/study_eligibility.py @@ -1,4 +1,5 @@ """API routes for study eligibility metadata""" + from flask import request from flask_restx import Resource, fields from jsonschema import ValidationError, validate diff --git a/apis/study_metadata/study_identification.py b/apis/study_metadata/study_identification.py index 503e699f..01a3a0fa 100644 --- a/apis/study_metadata/study_identification.py +++ b/apis/study_metadata/study_identification.py @@ -1,4 +1,5 @@ """API routes for study identification metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_intervention.py b/apis/study_metadata/study_intervention.py index 3accb513..e53fa828 100644 --- a/apis/study_metadata/study_intervention.py +++ b/apis/study_metadata/study_intervention.py @@ -1,4 +1,5 @@ """API routes for study intervention metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_ipdsharing.py b/apis/study_metadata/study_ipdsharing.py index ac49e5f5..27b7e166 100644 --- a/apis/study_metadata/study_ipdsharing.py +++ b/apis/study_metadata/study_ipdsharing.py @@ -1,4 +1,5 @@ """API routes for study ipdsharing metadata""" + import typing from flask import request diff --git a/apis/study_metadata/study_link.py b/apis/study_metadata/study_link.py index cd4d802a..78cbf417 100644 --- a/apis/study_metadata/study_link.py +++ b/apis/study_metadata/study_link.py @@ -1,4 +1,5 @@ """API routes for study link metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_location.py b/apis/study_metadata/study_location.py index 232f03b4..b017e235 100644 --- a/apis/study_metadata/study_location.py +++ b/apis/study_metadata/study_location.py @@ -1,4 +1,5 @@ """API routes for study location metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_other.py b/apis/study_metadata/study_other.py index a96fb386..46696303 100644 --- a/apis/study_metadata/study_other.py +++ b/apis/study_metadata/study_other.py @@ -1,4 +1,5 @@ """API routes for study other metadata""" + import typing from flask import request diff --git a/apis/study_metadata/study_overall_official.py b/apis/study_metadata/study_overall_official.py index 52345980..79eb4bb5 100644 --- a/apis/study_metadata/study_overall_official.py +++ b/apis/study_metadata/study_overall_official.py @@ -1,4 +1,5 @@ """API routes for study overall official metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_reference.py b/apis/study_metadata/study_reference.py index 40a27f2b..19e1b15d 100644 --- a/apis/study_metadata/study_reference.py +++ b/apis/study_metadata/study_reference.py @@ -1,4 +1,5 @@ """API routes for study reference metadata""" + import typing from flask import Response, request diff --git a/apis/study_metadata/study_sponsors_collaborators.py b/apis/study_metadata/study_sponsors_collaborators.py index 89ab8f2b..00d9885b 100644 --- a/apis/study_metadata/study_sponsors_collaborators.py +++ b/apis/study_metadata/study_sponsors_collaborators.py @@ -1,4 +1,5 @@ """API routes for study sponsors and collaborators metadata""" + import typing from flask import request diff --git a/apis/study_metadata/study_status.py b/apis/study_metadata/study_status.py index cd8a9b96..d0edbfce 100644 --- a/apis/study_metadata/study_status.py +++ b/apis/study_metadata/study_status.py @@ -1,4 +1,5 @@ """API routes for study status metadata""" + import typing from flask import request diff --git a/apis/utils.py b/apis/utils.py index c5a164c3..4bf07817 100644 --- a/apis/utils.py +++ b/apis/utils.py @@ -1,4 +1,5 @@ """Utils Endpoints""" + from flask import request from flask_restx import Namespace, Resource diff --git a/apis/utils_namespace.py b/apis/utils_namespace.py index beb9722c..8ef2bf09 100644 --- a/apis/utils_namespace.py +++ b/apis/utils_namespace.py @@ -1,4 +1,5 @@ """Namespace for utils operations""" + from flask_restx import Namespace api = Namespace("Utils", description="utils operations", path="/") diff --git a/app.py b/app.py index b26071d7..0c3a238b 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,5 @@ """Entry point for the application.""" + import datetime import importlib import logging diff --git a/config.py b/config.py index 6517a3a2..7666f32d 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ """Configuration for the application.""" + from os import environ from pathlib import Path from dotenv import dotenv_values diff --git a/core/__init__.py b/core/__init__.py index efb05b8e..b8fd69a2 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1,4 +1,3 @@ """Core package for the application.""" - from . import utils # noqa: F401 diff --git a/core/utils.py b/core/utils.py index c847973a..55f864ee 100644 --- a/core/utils.py +++ b/core/utils.py @@ -1,4 +1,5 @@ """Utils for core""" + import requests diff --git a/model/dataset_metadata/dataset_related_item.py b/model/dataset_metadata/dataset_related_item.py index f95db200..13b7b344 100644 --- a/model/dataset_metadata/dataset_related_item.py +++ b/model/dataset_metadata/dataset_related_item.py @@ -63,33 +63,51 @@ def to_dict(self): ], "creators": [c.to_dict() for c in creators], "contributors": [c.to_dict() for c in contributors], - "publication_year": self.dataset_related_item_other.publication_year - if self.dataset_related_item_other - else None, - "volume": self.dataset_related_item_other.volume - if self.dataset_related_item_other - else None, - "issue": self.dataset_related_item_other.issue - if self.dataset_related_item_other - else None, - "number_value": self.dataset_related_item_other.number_value - if self.dataset_related_item_other - else None, - "number_type": self.dataset_related_item_other.number_type - if self.dataset_related_item_other - else None, - "first_page": self.dataset_related_item_other.first_page - if self.dataset_related_item_other - else None, - "last_page": self.dataset_related_item_other.last_page - if self.dataset_related_item_other - else None, - "publisher": self.dataset_related_item_other.publisher - if self.dataset_related_item_other - else None, - "edition": self.dataset_related_item_other.edition - if self.dataset_related_item_other - else None, + "publication_year": ( + self.dataset_related_item_other.publication_year + if self.dataset_related_item_other + else None + ), + "volume": ( + self.dataset_related_item_other.volume + if self.dataset_related_item_other + else None + ), + "issue": ( + self.dataset_related_item_other.issue + if self.dataset_related_item_other + else None + ), + "number_value": ( + self.dataset_related_item_other.number_value + if self.dataset_related_item_other + else None + ), + "number_type": ( + self.dataset_related_item_other.number_type + if self.dataset_related_item_other + else None + ), + "first_page": ( + self.dataset_related_item_other.first_page + if self.dataset_related_item_other + else None + ), + "last_page": ( + self.dataset_related_item_other.last_page + if self.dataset_related_item_other + else None + ), + "publisher": ( + self.dataset_related_item_other.publisher + if self.dataset_related_item_other + else None + ), + "edition": ( + self.dataset_related_item_other.edition + if self.dataset_related_item_other + else None + ), "identifiers": [ i.to_dict() for i in self.dataset_related_item_identifier # type: ignore diff --git a/model/study.py b/model/study.py index 0c366e7e..a43208fc 100644 --- a/model/study.py +++ b/model/study.py @@ -165,9 +165,9 @@ def to_dict(self): "created_at": self.created_at, "updated_on": self.updated_on, "size": self.study_other.size if self.study_other else None, - "description": self.study_description.brief_summary - if self.study_description - else None, + "description": ( + self.study_description.brief_summary if self.study_description else None + ), "owner": owner.to_dict()["id"] if owner else None, "role": contributor_permission.to_dict()["role"], } diff --git a/model/study_contributor.py b/model/study_contributor.py index d277f8b4..7ba8eb21 100644 --- a/model/study_contributor.py +++ b/model/study_contributor.py @@ -30,9 +30,9 @@ def __init__(self, study: Study, user: User, permission): def to_dict(self): return { "id": self.user_id, - "name": self.user.user_details.first_name - if self.user.user_details - else None, + "name": ( + self.user.user_details.first_name if self.user.user_details else None + ), "email_address": self.user.email_address, "orcid": self.user.user_details.orcid if self.user.user_details else None, "role": self.permission, diff --git a/model/study_metadata/identifiers.py b/model/study_metadata/identifiers.py index cf9e14fa..9f7842ed 100644 --- a/model/study_metadata/identifiers.py +++ b/model/study_metadata/identifiers.py @@ -13,20 +13,22 @@ def to_dict(self): key=lambda i: i.created_at, ) return { - "primary": [ - identifier - for identifier in sorted_study_identifications - if not identifier.secondary - ][0].to_dict() - if len( + "primary": ( [ identifier for identifier in sorted_study_identifications if not identifier.secondary - ] - ) - != 0 # noqa: W503 - else None, + ][0].to_dict() + if len( + [ + identifier + for identifier in sorted_study_identifications + if not identifier.secondary + ] + ) + != 0 # noqa: W503 + else None + ), "secondary": [ identifier.to_dict() for identifier in sorted_study_identifications diff --git a/model/study_metadata/study_eligibility.py b/model/study_metadata/study_eligibility.py index 781c8cfc..1a636819 100644 --- a/model/study_metadata/study_eligibility.py +++ b/model/study_metadata/study_eligibility.py @@ -62,9 +62,9 @@ def to_dict(self): "exclusion_criteria": self.exclusion_criteria, "study_population": self.study_population, "sampling_method": self.sampling_method, - "study_type": self.study.study_design.study_type - if self.study.study_design - else None, + "study_type": ( + self.study.study_design.study_type if self.study.study_design else None + ), } def to_dict_metadata(self): diff --git a/model/version.py b/model/version.py index 6cfbfa83..cccb707c 100644 --- a/model/version.py +++ b/model/version.py @@ -69,7 +69,7 @@ def to_dict(self): "identifier": self.identifier, "doi": self.doi, "published": self.published, - "readme": self.version_readme.content if self.version_readme else "" + "readme": self.version_readme.content if self.version_readme else "", # "participants": [p.id for p in self.participants] # if isinstance(self.participants, (list, set)) # else [], diff --git a/pytest_config.py b/pytest_config.py index 9336ba61..4bce15c9 100644 --- a/pytest_config.py +++ b/pytest_config.py @@ -1,4 +1,5 @@ """Configuration for testing the application.""" + from os import environ from dotenv import dotenv_values diff --git a/tests/conftest.py b/tests/conftest.py index 4f8be7aa..355749e2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Defines fixtures available to all tests.""" + import json import os import unittest.mock diff --git a/tests/functional/test_server_launch.py b/tests/functional/test_server_launch.py index 7121b9d6..c97fe78f 100644 --- a/tests/functional/test_server_launch.py +++ b/tests/functional/test_server_launch.py @@ -1,4 +1,5 @@ """Tests for API endpoints related to server launch""" + import json diff --git a/tests/functional/test_study_api.py b/tests/functional/test_study_api.py index 2b9ce2e6..d70988a2 100644 --- a/tests/functional/test_study_api.py +++ b/tests/functional/test_study_api.py @@ -1,4 +1,5 @@ """Tests for API endpoints related to studies""" + import json import pytest diff --git a/tests/functional/test_study_dataset_api.py b/tests/functional/test_study_dataset_api.py index c77d2562..42fe42e3 100644 --- a/tests/functional/test_study_dataset_api.py +++ b/tests/functional/test_study_dataset_api.py @@ -1,4 +1,5 @@ """Tests for API endpoints related to datasets""" + import json import pytest