Skip to content

Commit

Permalink
style: automatic reformat
Browse files Browse the repository at this point in the history
auto reformat with ruff/docformatter/prettier after config changes
  • Loading branch information
alycejenni committed Oct 30, 2024
1 parent 00d32cd commit 164903e
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 29 deletions.
6 changes: 2 additions & 4 deletions ckanext/iiif/builders/abc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Optional

import abc
from typing import Optional


class IIIFResourceBuilder(abc.ABC):
Expand All @@ -12,8 +11,7 @@ class IIIFResourceBuilder(abc.ABC):
"""

@abc.abstractmethod
def match_and_build(self, identifier: str) -> Optional[dict]:
...
def match_and_build(self, identifier: str) -> Optional[dict]: ...

@abc.abstractmethod
def build_identifier(self, **kwargs) -> str:
Expand Down
11 changes: 6 additions & 5 deletions ckanext/iiif/builders/manifest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import re
from typing import Dict, List, Optional, Union

from ckan import model
from ckan.common import config
from ckan.lib.helpers import url_for_static_or_external
from ckan.logic import NotFound
from ckan.plugins import toolkit
from typing import List, Dict, Optional, Union

from .abc import IIIFResourceBuilder
from .utils import create_id_url, wrap_language, IIIFBuildError
from .utils import IIIFBuildError, create_id_url, wrap_language


class RecordManifestBuilder(IIIFResourceBuilder):
Expand Down Expand Up @@ -35,8 +36,8 @@ def match_and_build(self, identifier: str) -> Optional[dict]:
:param identifier: the manifest ID
:return: the manifest as a dict or None if the identifier wasn't a match to the
required format
:raise: IIIFBuildError if anything goes wrong after the identifier is matched
required format
:raises IIIFBuildError: if anything goes wrong after the identifier is matched
"""
regex = re.compile(
'resource/(?P<resource_id>.+?)/record/(?P<record_id>[^/]+).*$'
Expand Down Expand Up @@ -71,7 +72,7 @@ def build_record_manifest(resource: dict, record: dict) -> Optional[dict]:
:param resource: the resource dict
:param record: the record data
:return: the IIIF manifest for the record and its images
:raise: IIIFBuildError if no images are present on the record
:raises IIIFBuildError: if no images are present on the record
"""
manifest_id = RecordManifestBuilder._build_record_manifest_id(resource, record)

Expand Down
3 changes: 2 additions & 1 deletion ckanext/iiif/builders/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ckan.plugins import toolkit
from typing import Dict, List, Union

from ckan.plugins import toolkit


def create_id_url(identifier: str) -> str:
"""
Expand Down
3 changes: 2 additions & 1 deletion ckanext/iiif/interfaces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Callable, Optional, OrderedDict

from ckan.plugins import interfaces
from typing import Optional, Callable, OrderedDict


class IIIIF(interfaces.Interface):
Expand Down
5 changes: 3 additions & 2 deletions ckanext/iiif/logic/actions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
from collections import OrderedDict
from typing import Optional
from typing import OrderedDict as OrderedDictType

import logging
from ckan.plugins import toolkit
from ckantools.decorators import action
from typing import Optional, OrderedDict as OrderedDictType

from ..builders.abc import IIIFResourceBuilder
from ..builders.manifest import RecordManifestBuilder
Expand Down
8 changes: 4 additions & 4 deletions ckanext/iiif/plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import ckan.plugins as plugins
import logging
from contextlib import suppress

import ckan.plugins as plugins
from ckan.plugins import toolkit
from ckantools.loaders import create_actions, create_auth
from contextlib import suppress

from . import interfaces
from . import routes
from . import interfaces, routes
from .builders.manifest import RecordManifestBuilder
from .logic import actions, auth

Expand Down
1 change: 0 additions & 1 deletion docs/_scripts/gen_api_pages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# !/usr/bin/env python
# encoding: utf-8

"""
Generate the code reference pages and navigation.
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_actions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest.mock import MagicMock, patch

import pytest
from ckan.plugins import toolkit
from ckan.tests import factories
from unittest.mock import MagicMock, patch

from ckanext.iiif.builders.manifest import RecordManifestBuilder

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_iiif_route.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from unittest.mock import MagicMock, call, patch

import pytest
from unittest.mock import patch, MagicMock, call


@pytest.mark.ckan_config('ckan.plugins', 'iiif')
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/builders/test_manifest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from unittest.mock import MagicMock, patch

import pytest
from ckan.logic import NotFound
from ckan.plugins import toolkit
from ckan.tests import factories
from unittest.mock import patch, MagicMock

from ckanext.iiif.builders.manifest import RecordManifestBuilder
from ckanext.iiif.builders.utils import wrap_language, IIIFBuildError
from ckanext.iiif.builders.utils import IIIFBuildError, wrap_language


class TestBuildManifestID:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/builders/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ckanext.iiif.builders.utils import wrap_language
from mock import MagicMock

from ckanext.iiif.builders.utils import wrap_language


def test_wrap_language():
# use a mock to test that nothing gets changed (i.e. the function doesn't try to
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/logic/test_actions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from unittest.mock import MagicMock, patch

import pytest
from unittest.mock import patch, MagicMock

from ckanext.iiif.builders.manifest import RecordManifestBuilder
from ckanext.iiif.builders.utils import IIIFBuildError
from ckanext.iiif.logic.actions import build_iiif_resource, build_iiif_identifier
from ckanext.iiif.logic.actions import build_iiif_identifier, build_iiif_resource


class TestBuildIIIFResource:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/logic/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest.mock import MagicMock

from ckanext.iiif.logic.auth import build_iiif_resource, build_iiif_identifier
from ckanext.iiif.logic.auth import build_iiif_identifier, build_iiif_resource


class TestBuildIIIFResource:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/routes/test_iiif.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import MagicMock, patch

import pytest
from flask import Response
from unittest.mock import patch, MagicMock

from ckanext.iiif.routes.iiif import blueprint, resource

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import MagicMock, call, patch

import pytest
from ckan.tests import factories
from unittest.mock import patch, MagicMock, call

from ckanext.iiif.builders.manifest import RecordManifestBuilder
from ckanext.iiif.logic import actions
Expand Down

0 comments on commit 164903e

Please sign in to comment.