Skip to content

Commit

Permalink
chore: clean up imports
Browse files Browse the repository at this point in the history
* use relative imports for invenio_rdm_records
* remove unused imports
  • Loading branch information
max-moser committed Sep 7, 2023
1 parent b8ef65b commit e8a6ff0
Show file tree
Hide file tree
Showing 33 changed files with 41 additions and 77 deletions.
4 changes: 1 addition & 3 deletions invenio_rdm_records/access_requests_ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
# it under the terms of the MIT License; see LICENSE file for more details.

"""Access request UI views."""
from flask import Blueprint, abort, current_app, g, redirect, render_template, request
from flask_login import current_user
from flask import abort, current_app, g, redirect, render_template, request
from invenio_access.permissions import system_identity
from invenio_i18n import lazy_gettext as _
from invenio_mail.tasks import send_email
from invenio_requests.proxies import current_requests_service
from invenio_requests.views.decorators import pass_request
from invenio_users_resources.proxies import current_user_resources

from ..proxies import current_rdm_records_service as current_service
from ..requests.access.requests import GuestAcceptAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

"""Migrate secret links permission levels."""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

"""Remove PIDRelations tables."""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from sqlalchemy.engine.reflection import Inspector

# revision identifiers, used by Alembic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

"""Create RDM-Records branch."""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "b822ba22c688"
down_revision = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"""Add field to record consent to share personal data for access request."""

import sqlalchemy as sa
import sqlalchemy_utils
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "ffd725001655"
Expand Down
3 changes: 1 addition & 2 deletions invenio_rdm_records/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
from invenio_search.engine import dsl, search
from invenio_search.utils import build_alias_name

from invenio_rdm_records.proxies import current_rdm_records, current_rdm_records_service

from .fixtures import FixturesEngine
from .fixtures.demo import (
create_fake_community,
Expand All @@ -41,6 +39,7 @@
create_demo_record,
get_authenticated_identity,
)
from .proxies import current_rdm_records, current_rdm_records_service
from .utils import get_or_create_user

COMMUNITY_OWNER_EMAIL = "[email protected]"
Expand Down
15 changes: 6 additions & 9 deletions invenio_rdm_records/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@
from invenio_records_resources.resources.files import FileResource
from invenio_records_resources.services import FileService

from invenio_rdm_records.oaiserver.resources.config import OAIPMHServerResourceConfig
from invenio_rdm_records.oaiserver.resources.resources import OAIPMHServerResource
from invenio_rdm_records.oaiserver.services.config import OAIPMHServerServiceConfig
from invenio_rdm_records.oaiserver.services.services import OAIPMHServerService
from invenio_rdm_records.services.communities.service import RecordCommunitiesService
from invenio_rdm_records.services.community_inclusion.service import (
CommunityInclusionService,
)

from . import config
from .oaiserver.resources.config import OAIPMHServerResourceConfig
from .oaiserver.resources.resources import OAIPMHServerResource
from .oaiserver.services.config import OAIPMHServerServiceConfig
from .oaiserver.services.services import OAIPMHServerService
from .resources import (
IIIFResource,
IIIFResourceConfig,
Expand Down Expand Up @@ -59,6 +54,8 @@
RecordAccessService,
RecordRequestsService,
)
from .services.communities.service import RecordCommunitiesService
from .services.community_inclusion.service import CommunityInclusionService
from .services.config import (
RDMMediaFileDraftServiceConfig,
RDMMediaFileRecordServiceConfig,
Expand Down
1 change: 0 additions & 1 deletion invenio_rdm_records/fixtures/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""Fake demo records."""

import datetime
import json
import random
from pathlib import Path

Expand Down
6 changes: 1 addition & 5 deletions invenio_rdm_records/oaiserver/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
from invenio_records_resources.services.records.links import pagination_links
from sqlalchemy import asc, desc

from invenio_rdm_records.oaiserver.services.schema import (
OAIPMHMetadataFormat,
OAIPMHSetSchema,
)

from ..services.links import OAIPMHSetLink
from ..services.permissions import OAIPMHServerPermissionPolicy
from ..services.results import (
Expand All @@ -27,6 +22,7 @@
OAISetItem,
OAISetList,
)
from .schema import OAIPMHMetadataFormat, OAIPMHSetSchema


class SearchOptions:
Expand Down
4 changes: 2 additions & 2 deletions invenio_rdm_records/oaiserver/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.sql import text

from invenio_rdm_records.oaiserver.services.errors import (
from .errors import (
OAIPMHSetDoesNotExistError,
OAIPMHSetNotEditable,
OAIPMHSetSpecAlreadyExistsError,
)
from invenio_rdm_records.oaiserver.services.uow import OAISetCommitOp, OAISetDeleteOp
from .uow import OAISetCommitOp, OAISetDeleteOp


class OAIPMHServerService(Service):
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/records/dumpers/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from invenio_records.dumpers import SearchDumperExt

from invenio_rdm_records.records.systemfields.access.protection import Visibility
from ..systemfields.access.protection import Visibility


class FilesDumperExt(SearchDumperExt):
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/records/systemfields/draft_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Record():
from invenio_i18n import gettext as _
from invenio_records.systemfields import SystemField

from invenio_rdm_records.services.errors import RDMRecordsException, ReviewStateError
from ...services.errors import RDMRecordsException, ReviewStateError


class DraftStatus(SystemField):
Expand Down
3 changes: 1 addition & 2 deletions invenio_rdm_records/requests/community_inclusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
from invenio_requests.customizations import RequestType, actions
from invenio_requests.errors import CannotExecuteActionError

from invenio_rdm_records.services.errors import InvalidAccessRestrictions

from ..proxies import current_rdm_records_service as service
from ..services.errors import InvalidAccessRestrictions


def is_access_restriction_valid(record, community):
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/requests/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from invenio_requests import current_requests_service
from invenio_requests.services.requests.links import RequestLink, RequestLinksTemplate

from invenio_rdm_records.services.review.links import RequestRecordLink
from ..services.review.links import RequestRecordLink


def request_next_link(**kwargs):
Expand Down
3 changes: 1 addition & 2 deletions invenio_rdm_records/requests/entity_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
from invenio_users_resources.services.schemas import SystemUserSchema
from sqlalchemy.orm.exc import NoResultFound

from invenio_rdm_records.services.config import RDMRecordServiceConfig

from ..records.api import RDMDraft, RDMRecord
from ..services.config import RDMRecordServiceConfig
from ..services.dummy import DummyExpandingService

# NOTE: this is the python regex from https://emailregex.com/
Expand Down
2 changes: 0 additions & 2 deletions invenio_rdm_records/resources/deserializers/rocrate/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

"""RO-Crate schema."""

from distutils.log import error

from invenio_i18n import lazy_gettext as _
from marshmallow import EXCLUDE, Schema, ValidationError, fields, pre_load, validate
from marshmallow_utils.fields import SanitizedHTML, SanitizedUnicode
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/resources/serializers/dcat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pkg_resources import resource_stream
from werkzeug.utils import cached_property

from invenio_rdm_records.resources.serializers import DataCite43XMLSerializer
from .. import DataCite43XMLSerializer


class DCATSerializer(DataCite43XMLSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from flask_resources import BaseListSchema, MarshmallowSerializer
from flask_resources.serializers import JSONSerializer, SimpleSerializer

from invenio_rdm_records.contrib.journal.processors import JournalDublinCoreDumper
from invenio_rdm_records.contrib.meeting.processors import MeetingDublinCoreDumper

from ....contrib.journal.processors import JournalDublinCoreDumper
from ....contrib.meeting.processors import MeetingDublinCoreDumper
from .schema import DublinCoreSchema


Expand Down
4 changes: 1 addition & 3 deletions invenio_rdm_records/resources/serializers/ui/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from invenio_i18n import gettext as _
from marshmallow import fields

from invenio_rdm_records.records.systemfields.access.field.record import (
AccessStatusEnum,
)
from ....records.systemfields.access.field.record import AccessStatusEnum


class UIAccessStatus(object):
Expand Down
1 change: 0 additions & 1 deletion invenio_rdm_records/secret_links/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from datetime import date, datetime

from invenio_db import db
from itsdangerous import BadData
from sqlalchemy_utils import UUIDType

from .errors import InvalidPermissionLevelError
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/services/access/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import datetime, timedelta

import arrow
from flask import current_app, url_for
from flask import current_app
from flask_login import current_user
from invenio_access.permissions import authenticated_user, system_identity
from invenio_drafts_resources.services.records import RecordService
Expand Down
10 changes: 4 additions & 6 deletions invenio_rdm_records/services/communities/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@
from invenio_search.engine import dsl
from sqlalchemy.orm.exc import NoResultFound

from invenio_rdm_records.notifications.builders import (
CommunityInclusionSubmittedNotificationBuilder,
)
from invenio_rdm_records.proxies import current_rdm_records, current_rdm_records_service
from invenio_rdm_records.requests import CommunityInclusion
from invenio_rdm_records.services.errors import (
from ...notifications.builders import CommunityInclusionSubmittedNotificationBuilder
from ...proxies import current_rdm_records, current_rdm_records_service
from ...requests import CommunityInclusion
from ..errors import (
CommunityAlreadyExists,
InvalidAccessRestrictions,
OpenRequestAlreadyExists,
Expand Down
7 changes: 3 additions & 4 deletions invenio_rdm_records/services/community_inclusion/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@

from flask import current_app
from invenio_communities import current_communities
from invenio_i18n import lazy_gettext as _
from invenio_requests import current_requests_service

from invenio_rdm_records.requests.community_inclusion import (
from ...requests.community_inclusion import (
CommunityInclusion,
is_access_restriction_valid,
)
from invenio_rdm_records.requests.community_submission import CommunitySubmission
from invenio_rdm_records.services.errors import InvalidAccessRestrictions
from ...requests.community_submission import CommunitySubmission
from ..errors import InvalidAccessRestrictions


class CommunityInclusionService:
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/services/community_records/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from invenio_records_resources.services.uow import unit_of_work
from invenio_search.engine import dsl

from invenio_rdm_records.proxies import current_record_communities_service
from ...proxies import current_record_communities_service


class CommunityRecordsService(RecordService):
Expand Down
1 change: 0 additions & 1 deletion invenio_rdm_records/services/components/verified.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from flask import current_app
from invenio_access.permissions import system_identity
from invenio_drafts_resources.services.records.components import ServiceComponent
from invenio_i18n import lazy_gettext as _
from invenio_requests.tasks import request_moderation


Expand Down
3 changes: 1 addition & 2 deletions invenio_rdm_records/services/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
from invenio_records_resources.services.files.transfer import TransferType
from invenio_search.engine import dsl

from invenio_rdm_records.records import RDMDraft

from ..records import RDMDraft
from ..records.systemfields.access.grants import Grant
from ..requests.access import AccessRequestTokenNeed
from ..tokens.permissions import RATNeed
Expand Down
8 changes: 4 additions & 4 deletions invenio_rdm_records/services/github/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from invenio_github.models import ReleaseStatus
from invenio_records_resources.services.uow import UnitOfWork

from invenio_rdm_records.proxies import current_rdm_records_service
from invenio_rdm_records.resources.serializers.ui import UIJSONSerializer
from invenio_rdm_records.services.github.metadata import RDMReleaseMetadata
from invenio_rdm_records.services.github.utils import retrieve_recid_by_uuid
from ...proxies import current_rdm_records_service
from ...resources.serializers.ui import UIJSONSerializer
from .metadata import RDMReleaseMetadata
from .utils import retrieve_recid_by_uuid


class RDMGithubRelease(GitHubRelease):
Expand Down
2 changes: 0 additions & 2 deletions invenio_rdm_records/services/github/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# it under the terms of the MIT License; see LICENSE file for more details.
"""Utility functions."""

from flask import current_app
from invenio_pidstore.models import PersistentIdentifier
from marshmallow import Schema


def retrieve_recid_by_uuid(rec_uuid):
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/services/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
SystemProcess,
)
from invenio_records_permissions.policies.records import RecordPermissionPolicy
from invenio_requests.services.generators import Creator, Receiver, Status
from invenio_requests.services.generators import Receiver, Status
from invenio_requests.services.permissions import (
PermissionPolicy as RequestPermissionPolicy,
)
Expand Down
3 changes: 1 addition & 2 deletions invenio_rdm_records/services/pids/providers/datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from invenio_i18n import lazy_gettext as _
from invenio_pidstore.models import PIDStatus

from invenio_rdm_records.resources.serializers import DataCite43JSONSerializer

from ....resources.serializers import DataCite43JSONSerializer
from .base import PIDProvider


Expand Down
4 changes: 2 additions & 2 deletions invenio_rdm_records/services/pids/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from invenio_requests.services.results import EntityResolverExpandableField
from sqlalchemy.orm.exc import NoResultFound

from invenio_rdm_records.services.results import ParentCommunitiesExpandableField
from invenio_rdm_records.utils import ChainObject
from ...utils import ChainObject
from ..results import ParentCommunitiesExpandableField


class PIDsService(RecordService):
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/services/pids/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from celery import shared_task
from invenio_access.permissions import system_identity

from invenio_rdm_records.proxies import current_rdm_records
from ...proxies import current_rdm_records


@shared_task(ignore_result=True)
Expand Down
5 changes: 2 additions & 3 deletions invenio_rdm_records/services/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from celery import shared_task
from flask import current_app
from invenio_access.permissions import system_identity
from invenio_i18n import lazy_gettext as _

from invenio_rdm_records.proxies import current_rdm_records
from invenio_rdm_records.services.errors import EmbargoNotLiftedError
from ..proxies import current_rdm_records
from .errors import EmbargoNotLiftedError


@shared_task(ignore_result=True)
Expand Down

0 comments on commit e8a6ff0

Please sign in to comment.