From b434d3231c3b149cee785099ad1ba4494ac183c7 Mon Sep 17 00:00:00 2001 From: RayBB Date: Wed, 27 Nov 2024 11:00:07 -0500 Subject: [PATCH] isort tests/mocks/utils --- openlibrary/conftest.py | 5 ++--- openlibrary/mocks/mock_ia.py | 1 + openlibrary/mocks/mock_infobase.py | 8 ++++---- openlibrary/mocks/mock_ol.py | 6 ++++-- openlibrary/mocks/tests/test_mock_infobase.py | 1 + openlibrary/mocks/tests/test_mock_memcache.py | 3 ++- openlibrary/tests/accounts/test_models.py | 6 ++++-- openlibrary/tests/catalog/test_get_ia.py | 9 +++++---- openlibrary/tests/catalog/test_utils.py | 3 ++- openlibrary/tests/core/conftest.py | 1 + openlibrary/tests/core/lists/test_model.py | 2 +- openlibrary/tests/core/test_connections.py | 3 ++- openlibrary/tests/core/test_db.py | 5 +++-- openlibrary/tests/core/test_fulltext.py | 2 ++ openlibrary/tests/core/test_helpers.py | 1 + openlibrary/tests/core/test_i18n.py | 2 +- openlibrary/tests/core/test_imports.py | 4 ++-- openlibrary/tests/core/test_models.py | 5 +++-- openlibrary/tests/core/test_processors.py | 5 +++-- openlibrary/tests/core/test_processors_invalidation.py | 3 ++- openlibrary/tests/core/test_unmarshal.py | 2 +- openlibrary/tests/core/test_vendors.py | 9 +++++---- openlibrary/tests/core/test_waitinglist.py | 6 ++++-- openlibrary/tests/core/test_wikidata.py | 6 ++++-- openlibrary/tests/data/test_dump.py | 2 +- openlibrary/tests/solr/test_query_utils.py | 5 +++-- openlibrary/tests/solr/test_types_generator.py | 1 - openlibrary/tests/solr/test_update.py | 2 +- openlibrary/tests/solr/test_utils.py | 2 +- openlibrary/tests/solr/updater/test_author.py | 1 + openlibrary/tests/solr/updater/test_edition.py | 2 +- openlibrary/tests/solr/updater/test_work.py | 1 + openlibrary/utils/__init__.py | 6 +++--- openlibrary/utils/bulkimport.py | 5 +++-- openlibrary/utils/dateutil.py | 1 - openlibrary/utils/ddc.py | 3 ++- openlibrary/utils/decorators.py | 4 ++-- openlibrary/utils/form.py | 3 ++- openlibrary/utils/ia.py | 2 +- openlibrary/utils/isbn.py | 1 + openlibrary/utils/lcc.py | 1 + openlibrary/utils/lccn.py | 1 - openlibrary/utils/olmemcache.py | 3 ++- openlibrary/utils/open_syllabus_project.py | 4 ++-- openlibrary/utils/processors.py | 3 ++- openlibrary/utils/sentry.py | 6 +++--- openlibrary/utils/solr.py | 6 ++---- openlibrary/utils/tests/test_dateutil.py | 3 ++- openlibrary/utils/tests/test_isbn.py | 3 ++- openlibrary/utils/tests/test_lccn.py | 1 + openlibrary/utils/tests/test_processors.py | 3 ++- openlibrary/utils/tests/test_retry.py | 2 ++ tests/test_docker_compose.py | 1 + 53 files changed, 105 insertions(+), 71 deletions(-) diff --git a/openlibrary/conftest.py b/openlibrary/conftest.py index c00dbc804a9..49239c88eb1 100644 --- a/openlibrary/conftest.py +++ b/openlibrary/conftest.py @@ -7,13 +7,12 @@ from infogami.infobase.tests.pytest_wildcard import Wildcard from infogami.utils import template from infogami.utils.view import render_template as infobase_render_template -from openlibrary.i18n import gettext from openlibrary.core import helpers - +from openlibrary.i18n import gettext +from openlibrary.mocks.mock_ia import mock_ia # noqa: F401 side effects may be needed from openlibrary.mocks.mock_infobase import ( mock_site, # noqa: F401 side effects may be needed ) -from openlibrary.mocks.mock_ia import mock_ia # noqa: F401 side effects may be needed from openlibrary.mocks.mock_memcache import ( mock_memcache, # noqa: F401 side effects may be needed ) diff --git a/openlibrary/mocks/mock_ia.py b/openlibrary/mocks/mock_ia.py index c516229738f..445a29b777e 100644 --- a/openlibrary/mocks/mock_ia.py +++ b/openlibrary/mocks/mock_ia.py @@ -2,6 +2,7 @@ """ import pytest + from openlibrary.core import ia diff --git a/openlibrary/mocks/mock_infobase.py b/openlibrary/mocks/mock_infobase.py index 5110c4069b3..555080a324d 100644 --- a/openlibrary/mocks/mock_infobase.py +++ b/openlibrary/mocks/mock_infobase.py @@ -5,17 +5,17 @@ import itertools import json import re +from datetime import datetime + import pytest import web -from datetime import datetime - -from infogami.infobase import client, common, account, config as infobase_config from infogami import config +from infogami.infobase import account, client, common +from infogami.infobase import config as infobase_config from openlibrary.plugins.upstream.models import Changeset from openlibrary.plugins.upstream.utils import safeget - key_patterns = { 'work': '/works/OL%dW', 'edition': '/books/OL%dM', diff --git a/openlibrary/mocks/mock_ol.py b/openlibrary/mocks/mock_ol.py index 62888fec77b..6d43fabc8c7 100644 --- a/openlibrary/mocks/mock_ol.py +++ b/openlibrary/mocks/mock_ol.py @@ -1,6 +1,8 @@ -import pytest import re + +import pytest import web + from infogami import config from infogami.utils import delegate @@ -9,7 +11,7 @@ except ImportError: # older versions of web.py from web import AppBrowser -from openlibrary.mocks.mock_infobase import mock_site, MockConnection +from openlibrary.mocks.mock_infobase import MockConnection, mock_site from openlibrary.plugins import ol_infobase diff --git a/openlibrary/mocks/tests/test_mock_infobase.py b/openlibrary/mocks/tests/test_mock_infobase.py index 31a29ae41c5..23deb1789f8 100644 --- a/openlibrary/mocks/tests/test_mock_infobase.py +++ b/openlibrary/mocks/tests/test_mock_infobase.py @@ -1,4 +1,5 @@ import datetime + import web diff --git a/openlibrary/mocks/tests/test_mock_memcache.py b/openlibrary/mocks/tests/test_mock_memcache.py index 4f74d549b8b..b26d009a559 100644 --- a/openlibrary/mocks/tests/test_mock_memcache.py +++ b/openlibrary/mocks/tests/test_mock_memcache.py @@ -1,6 +1,7 @@ -from .. import mock_memcache import memcache +from .. import mock_memcache + class Test_mock_memcache: def test_set(self): diff --git a/openlibrary/tests/accounts/test_models.py b/openlibrary/tests/accounts/test_models.py index 1600844c7f4..6fb2adc03be 100644 --- a/openlibrary/tests/accounts/test_models.py +++ b/openlibrary/tests/accounts/test_models.py @@ -1,7 +1,9 @@ -from openlibrary.accounts import model, InternetArchiveAccount, OpenLibraryAccount -from requests.models import Response from unittest import mock +from requests.models import Response + +from openlibrary.accounts import InternetArchiveAccount, OpenLibraryAccount, model + def get_username(account): return account and account.value diff --git a/openlibrary/tests/catalog/test_get_ia.py b/openlibrary/tests/catalog/test_get_ia.py index ecc7605ce59..e57201ee5b4 100644 --- a/openlibrary/tests/catalog/test_get_ia.py +++ b/openlibrary/tests/catalog/test_get_ia.py @@ -1,10 +1,11 @@ -import pytest from pathlib import Path + +import pytest + from openlibrary.catalog import get_ia -from openlibrary.core import ia +from openlibrary.catalog.marc.marc_binary import BadLength, BadMARC, MarcBinary from openlibrary.catalog.marc.marc_xml import MarcXml -from openlibrary.catalog.marc.marc_binary import MarcBinary, BadLength, BadMARC - +from openlibrary.core import ia TEST_DATA = Path(__file__).parents[2] / 'catalog' / 'marc' / 'tests' / 'test_data' diff --git a/openlibrary/tests/catalog/test_utils.py b/openlibrary/tests/catalog/test_utils.py index d09ef1eba23..fc770d5e996 100644 --- a/openlibrary/tests/catalog/test_utils.py +++ b/openlibrary/tests/catalog/test_utils.py @@ -1,6 +1,7 @@ +from datetime import datetime, timedelta + import pytest -from datetime import datetime, timedelta from openlibrary.catalog.utils import ( author_dates_match, flip_name, diff --git a/openlibrary/tests/core/conftest.py b/openlibrary/tests/core/conftest.py index 5e502a7db7f..e95858ab978 100644 --- a/openlibrary/tests/core/conftest.py +++ b/openlibrary/tests/core/conftest.py @@ -1,4 +1,5 @@ import os + import pytest diff --git a/openlibrary/tests/core/lists/test_model.py b/openlibrary/tests/core/lists/test_model.py index e7c77dddbb9..c27ea754030 100644 --- a/openlibrary/tests/core/lists/test_model.py +++ b/openlibrary/tests/core/lists/test_model.py @@ -1,5 +1,5 @@ -from openlibrary.mocks.mock_infobase import MockSite import openlibrary.core.lists.model as list_model +from openlibrary.mocks.mock_infobase import MockSite class TestList: diff --git a/openlibrary/tests/core/test_connections.py b/openlibrary/tests/core/test_connections.py index f0c260dfbc3..5acb5a228e5 100644 --- a/openlibrary/tests/core/test_connections.py +++ b/openlibrary/tests/core/test_connections.py @@ -1,7 +1,8 @@ # This will be moved to core soon. -from openlibrary.plugins.openlibrary import connection as connections import json +from openlibrary.plugins.openlibrary import connection as connections + class MockConnection: def __init__(self): diff --git a/openlibrary/tests/core/test_db.py b/openlibrary/tests/core/test_db.py index b0c7625594d..33caf42efaa 100644 --- a/openlibrary/tests/core/test_db.py +++ b/openlibrary/tests/core/test_db.py @@ -1,8 +1,9 @@ import web -from openlibrary.core.db import get_db + +from openlibrary.core.booknotes import Booknotes from openlibrary.core.bookshelves import Bookshelves from openlibrary.core.bookshelves_events import BookshelvesEvents -from openlibrary.core.booknotes import Booknotes +from openlibrary.core.db import get_db from openlibrary.core.edits import CommunityEditsQueue from openlibrary.core.observations import Observations from openlibrary.core.ratings import Ratings diff --git a/openlibrary/tests/core/test_fulltext.py b/openlibrary/tests/core/test_fulltext.py index 3c378a22113..dae630a5fc5 100644 --- a/openlibrary/tests/core/test_fulltext.py +++ b/openlibrary/tests/core/test_fulltext.py @@ -1,6 +1,8 @@ from json.decoder import JSONDecodeError from unittest.mock import Mock, patch + import requests + from infogami import config from openlibrary.core import fulltext diff --git a/openlibrary/tests/core/test_helpers.py b/openlibrary/tests/core/test_helpers.py index 28f30ccbeb1..c5393e81ab7 100644 --- a/openlibrary/tests/core/test_helpers.py +++ b/openlibrary/tests/core/test_helpers.py @@ -1,4 +1,5 @@ import web + from openlibrary.core import helpers as h from openlibrary.mocks.mock_infobase import MockSite diff --git a/openlibrary/tests/core/test_i18n.py b/openlibrary/tests/core/test_i18n.py index 39e0e94b903..229873e73a6 100644 --- a/openlibrary/tests/core/test_i18n.py +++ b/openlibrary/tests/core/test_i18n.py @@ -1,8 +1,8 @@ import web -from openlibrary.mocks.mock_infobase import MockSite # The i18n module should be moved to core. from openlibrary import i18n +from openlibrary.mocks.mock_infobase import MockSite class MockTranslations(dict): diff --git a/openlibrary/tests/core/test_imports.py b/openlibrary/tests/core/test_imports.py index e8e2738c038..03dbff5c3aa 100644 --- a/openlibrary/tests/core/test_imports.py +++ b/openlibrary/tests/core/test_imports.py @@ -1,11 +1,11 @@ -import pytest from typing import Final + +import pytest import web from openlibrary.core.db import get_db from openlibrary.core.imports import Batch, ImportItem - IMPORT_ITEM_DDL: Final = """ CREATE TABLE import_item ( id serial primary key, diff --git a/openlibrary/tests/core/test_models.py b/openlibrary/tests/core/test_models.py index 0b49e2082dd..3ffa355d8db 100644 --- a/openlibrary/tests/core/test_models.py +++ b/openlibrary/tests/core/test_models.py @@ -1,7 +1,7 @@ -from openlibrary.core import models - import pytest +from openlibrary.core import models + class MockSite: def get(self, key): @@ -154,6 +154,7 @@ def test_resolve_redirect_chain(self, monkeypatch): work4 = {"key": work4_key, "type": type_work} import web + from openlibrary.mocks import mock_infobase site = mock_infobase.MockSite() diff --git a/openlibrary/tests/core/test_processors.py b/openlibrary/tests/core/test_processors.py index 4d182a40c36..ab454af7947 100644 --- a/openlibrary/tests/core/test_processors.py +++ b/openlibrary/tests/core/test_processors.py @@ -1,7 +1,8 @@ -from openlibrary.core.processors import readableurls as processors -from infogami.infobase import client, common import web +from infogami.infobase import client, common +from openlibrary.core.processors import readableurls as processors + class MockSite: def __init__(self): diff --git a/openlibrary/tests/core/test_processors_invalidation.py b/openlibrary/tests/core/test_processors_invalidation.py index 1cc1915edc5..2a0d712a0b1 100644 --- a/openlibrary/tests/core/test_processors_invalidation.py +++ b/openlibrary/tests/core/test_processors_invalidation.py @@ -1,6 +1,7 @@ -import web import datetime +import web + from infogami.infobase import client from openlibrary.core.processors import invalidation from openlibrary.mocks.mock_infobase import MockSite diff --git a/openlibrary/tests/core/test_unmarshal.py b/openlibrary/tests/core/test_unmarshal.py index 6eb67f957df..cc774c1393c 100644 --- a/openlibrary/tests/core/test_unmarshal.py +++ b/openlibrary/tests/core/test_unmarshal.py @@ -1,5 +1,5 @@ -from datetime import datetime import re +from datetime import datetime import pytest diff --git a/openlibrary/tests/core/test_vendors.py b/openlibrary/tests/core/test_vendors.py index bd0c9bf53ee..fda101a666c 100644 --- a/openlibrary/tests/core/test_vendors.py +++ b/openlibrary/tests/core/test_vendors.py @@ -2,13 +2,14 @@ from unittest.mock import patch import pytest + from openlibrary.core.vendors import ( - get_amazon_metadata, - split_amazon_title, - clean_amazon_metadata_for_load, - betterworldbooks_fmt, AmazonAPI, + betterworldbooks_fmt, + clean_amazon_metadata_for_load, + get_amazon_metadata, is_dvd, + split_amazon_title, ) diff --git a/openlibrary/tests/core/test_waitinglist.py b/openlibrary/tests/core/test_waitinglist.py index 81bdb8e4f07..d50ce157f4b 100644 --- a/openlibrary/tests/core/test_waitinglist.py +++ b/openlibrary/tests/core/test_waitinglist.py @@ -1,8 +1,10 @@ -from openlibrary.core.waitinglist import WaitingLoan -from openlibrary.core import lending import json + import pytest +from openlibrary.core import lending +from openlibrary.core.waitinglist import WaitingLoan + class TestWaitingLoan: def test_new(self, monkeypatch): diff --git a/openlibrary/tests/core/test_wikidata.py b/openlibrary/tests/core/test_wikidata.py index 97632046a4d..d5a1505de1b 100644 --- a/openlibrary/tests/core/test_wikidata.py +++ b/openlibrary/tests/core/test_wikidata.py @@ -1,7 +1,9 @@ -import pytest +from datetime import datetime, timedelta from unittest.mock import patch + +import pytest + from openlibrary.core import wikidata -from datetime import datetime, timedelta EXAMPLE_WIKIDATA_DICT = { 'id': "Q42", diff --git a/openlibrary/tests/data/test_dump.py b/openlibrary/tests/data/test_dump.py index f5d97e03b2d..6331f704447 100644 --- a/openlibrary/tests/data/test_dump.py +++ b/openlibrary/tests/data/test_dump.py @@ -1,6 +1,6 @@ import json -from openlibrary.data.dump import print_dump, pgdecode +from openlibrary.data.dump import pgdecode, print_dump class TestPrintDump: diff --git a/openlibrary/tests/solr/test_query_utils.py b/openlibrary/tests/solr/test_query_utils.py index f8808c4df19..94df64a41c4 100644 --- a/openlibrary/tests/solr/test_query_utils.py +++ b/openlibrary/tests/solr/test_query_utils.py @@ -1,12 +1,13 @@ import pytest + from openlibrary.solr.query_utils import ( EmptyTreeError, luqum_parser, luqum_remove_child, + luqum_remove_field, luqum_replace_child, - luqum_traverse, luqum_replace_field, - luqum_remove_field, + luqum_traverse, ) REMOVE_TESTS = { diff --git a/openlibrary/tests/solr/test_types_generator.py b/openlibrary/tests/solr/test_types_generator.py index b8d7d44ef04..17eb4b10050 100644 --- a/openlibrary/tests/solr/test_types_generator.py +++ b/openlibrary/tests/solr/test_types_generator.py @@ -2,7 +2,6 @@ from openlibrary.solr.types_generator import generate - root = os.path.dirname(__file__) diff --git a/openlibrary/tests/solr/test_update.py b/openlibrary/tests/solr/test_update.py index e850c15ffd1..d450fa9cf2f 100644 --- a/openlibrary/tests/solr/test_update.py +++ b/openlibrary/tests/solr/test_update.py @@ -1,6 +1,6 @@ import pytest -from openlibrary.core.ratings import WorkRatingsSummary +from openlibrary.core.ratings import WorkRatingsSummary from openlibrary.solr import update from openlibrary.solr.data_provider import DataProvider, WorkReadingLogSolrSummary diff --git a/openlibrary/tests/solr/test_utils.py b/openlibrary/tests/solr/test_utils.py index eafd7c80222..f63c8f09697 100644 --- a/openlibrary/tests/solr/test_utils.py +++ b/openlibrary/tests/solr/test_utils.py @@ -2,7 +2,7 @@ from unittest.mock import MagicMock import httpx -from httpx import Response, ConnectError +from httpx import ConnectError, Response from openlibrary.solr.utils import SolrUpdateRequest, solr_update diff --git a/openlibrary/tests/solr/updater/test_author.py b/openlibrary/tests/solr/updater/test_author.py index 0c65f4bb49d..94dda1a9d5d 100644 --- a/openlibrary/tests/solr/updater/test_author.py +++ b/openlibrary/tests/solr/updater/test_author.py @@ -1,5 +1,6 @@ import httpx import pytest + from openlibrary.solr.updater.author import AuthorSolrUpdater from openlibrary.tests.solr.test_update import FakeDataProvider, make_author diff --git a/openlibrary/tests/solr/updater/test_edition.py b/openlibrary/tests/solr/updater/test_edition.py index f9723868189..74984cbd4f1 100644 --- a/openlibrary/tests/solr/updater/test_edition.py +++ b/openlibrary/tests/solr/updater/test_edition.py @@ -1,6 +1,6 @@ import pytest -from openlibrary.solr.updater.edition import EditionSolrUpdater +from openlibrary.solr.updater.edition import EditionSolrUpdater from openlibrary.tests.solr.test_update import FakeDataProvider diff --git a/openlibrary/tests/solr/updater/test_work.py b/openlibrary/tests/solr/updater/test_work.py index 0a919d5a21c..ee7116873eb 100644 --- a/openlibrary/tests/solr/updater/test_work.py +++ b/openlibrary/tests/solr/updater/test_work.py @@ -1,4 +1,5 @@ import pytest + from openlibrary.solr.updater.work import ( WorkSolrBuilder, WorkSolrUpdater, diff --git a/openlibrary/utils/__init__.py b/openlibrary/utils/__init__.py index 31a785d3ee0..ab5c7c2c036 100644 --- a/openlibrary/utils/__init__.py +++ b/openlibrary/utils/__init__.py @@ -1,10 +1,10 @@ """Generic utilities""" -from enum import Enum import re +from collections.abc import Callable, Iterable +from enum import Enum from subprocess import CalledProcessError, run -from typing import TypeVar, Literal -from collections.abc import Iterable, Callable +from typing import Literal, TypeVar to_drop = set(''';/?:@&=+$,<>#%"{}|\\^[]`\n\r''') diff --git a/openlibrary/utils/bulkimport.py b/openlibrary/utils/bulkimport.py index 497a02759a0..909932f0b98 100644 --- a/openlibrary/utils/bulkimport.py +++ b/openlibrary/utils/bulkimport.py @@ -2,12 +2,13 @@ going through infobase API. """ +import datetime import json import os -import web -import datetime from collections import defaultdict +import web + class DocumentLoader: def __init__(self, **params): diff --git a/openlibrary/utils/dateutil.py b/openlibrary/utils/dateutil.py index 6a740a67ee4..b9ef5a7fb46 100644 --- a/openlibrary/utils/dateutil.py +++ b/openlibrary/utils/dateutil.py @@ -9,7 +9,6 @@ from infogami.utils.view import public - MINUTE_SECS = 60 HALF_HOUR_SECS = MINUTE_SECS * 30 HOUR_SECS = MINUTE_SECS * 60 diff --git a/openlibrary/utils/ddc.py b/openlibrary/utils/ddc.py index 58512122fad..1b4dc531646 100644 --- a/openlibrary/utils/ddc.py +++ b/openlibrary/utils/ddc.py @@ -8,9 +8,10 @@ """ from __future__ import annotations + import re -from string import printable from collections.abc import Iterable +from string import printable MULTIPLE_SPACES_RE = re.compile(r'\s+') DDC_RE = re.compile( diff --git a/openlibrary/utils/decorators.py b/openlibrary/utils/decorators.py index ec280276d6f..97db3e1c0cd 100644 --- a/openlibrary/utils/decorators.py +++ b/openlibrary/utils/decorators.py @@ -1,7 +1,7 @@ -import web - from functools import wraps +import web + from openlibrary.accounts import get_current_user diff --git a/openlibrary/utils/form.py b/openlibrary/utils/form.py index eb16b05c1b1..a664b46f0fb 100644 --- a/openlibrary/utils/form.py +++ b/openlibrary/utils/form.py @@ -3,10 +3,11 @@ (this should go to web.py) """ -import web import copy import re +import web + from infogami.utils.view import render diff --git a/openlibrary/utils/ia.py b/openlibrary/utils/ia.py index 1dc7253b87c..1eb793a05bb 100644 --- a/openlibrary/utils/ia.py +++ b/openlibrary/utils/ia.py @@ -1,5 +1,5 @@ -from socket import socket, AF_INET, SOCK_DGRAM, SOL_UDP, SO_BROADCAST import re +from socket import AF_INET, SO_BROADCAST, SOCK_DGRAM, SOL_UDP, socket re_loc = re.compile(r'^(ia\d+\.us\.archive\.org):(/\d+/items/(.*))$') diff --git a/openlibrary/utils/isbn.py b/openlibrary/utils/isbn.py index d36a27cf1e4..cbb2e3e82f6 100644 --- a/openlibrary/utils/isbn.py +++ b/openlibrary/utils/isbn.py @@ -1,4 +1,5 @@ from __future__ import annotations + from isbnlib import canonical diff --git a/openlibrary/utils/lcc.py b/openlibrary/utils/lcc.py index 76c0cdcea21..ec0ea7fa1d2 100644 --- a/openlibrary/utils/lcc.py +++ b/openlibrary/utils/lcc.py @@ -86,6 +86,7 @@ class number fixed-width. For example: """ from __future__ import annotations + import re from collections.abc import Iterable diff --git a/openlibrary/utils/lccn.py b/openlibrary/utils/lccn.py index 64c683d8be9..abf79f781da 100644 --- a/openlibrary/utils/lccn.py +++ b/openlibrary/utils/lccn.py @@ -1,6 +1,5 @@ import re - REV_RE = re.compile(r'rev.*') REMOVESUFFIX_RE = re.compile(r'[^\/]+') HYPHEN_RE = re.compile(r'(.+)-+([0-9]+)') diff --git a/openlibrary/utils/olmemcache.py b/openlibrary/utils/olmemcache.py index 25abe14c905..47fe4060954 100644 --- a/openlibrary/utils/olmemcache.py +++ b/openlibrary/utils/olmemcache.py @@ -1,9 +1,10 @@ """Memcache interface to store data in memcached.""" import memcache -from openlibrary.utils.olcompress import OLCompressor import web +from openlibrary.utils.olcompress import OLCompressor + class Client: """Wrapper to memcache Client to enable OL specific compression and unicode keys. diff --git a/openlibrary/utils/open_syllabus_project.py b/openlibrary/utils/open_syllabus_project.py index 0260f536c4d..adeb81d52c3 100644 --- a/openlibrary/utils/open_syllabus_project.py +++ b/openlibrary/utils/open_syllabus_project.py @@ -1,8 +1,8 @@ +import gzip +import json import logging import os -import json import sqlite3 -import gzip from contextlib import closing from pathlib import Path diff --git a/openlibrary/utils/processors.py b/openlibrary/utils/processors.py index 5e805e3fb39..125378a65ee 100644 --- a/openlibrary/utils/processors.py +++ b/openlibrary/utils/processors.py @@ -1,9 +1,10 @@ """Generic web.py application processors. """ -import web import time +import web + __all__ = ["RateLimitProcessor"] diff --git a/openlibrary/utils/sentry.py b/openlibrary/utils/sentry.py index 00e933812c2..504008fa1bf 100644 --- a/openlibrary/utils/sentry.py +++ b/openlibrary/utils/sentry.py @@ -1,17 +1,17 @@ -from dataclasses import dataclass import logging import re +from dataclasses import dataclass import sentry_sdk import web +from sentry_sdk.tracing import TRANSACTION_SOURCE_ROUTE, Transaction from sentry_sdk.utils import capture_internal_exceptions -from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE + from infogami.utils.app import ( find_page, modes, ) from infogami.utils.types import type_patterns - from openlibrary.utils import get_software_version diff --git a/openlibrary/utils/solr.py b/openlibrary/utils/solr.py index 09de9e60c13..6eb7770eee7 100644 --- a/openlibrary/utils/solr.py +++ b/openlibrary/utils/solr.py @@ -2,15 +2,13 @@ import logging import re -from typing import TypeVar from collections.abc import Callable, Iterable +from typing import TypeVar +from urllib.parse import urlencode, urlsplit import requests import web -from urllib.parse import urlencode, urlsplit - - logger = logging.getLogger("openlibrary.logger") diff --git a/openlibrary/utils/tests/test_dateutil.py b/openlibrary/utils/tests/test_dateutil.py index c6922d1840e..4bbb85247a9 100644 --- a/openlibrary/utils/tests/test_dateutil.py +++ b/openlibrary/utils/tests/test_dateutil.py @@ -1,6 +1,7 @@ -from .. import dateutil import datetime +from .. import dateutil + def test_parse_date(): assert dateutil.parse_date("2010") == datetime.date(2010, 1, 1) diff --git a/openlibrary/utils/tests/test_isbn.py b/openlibrary/utils/tests/test_isbn.py index 07bb6dc4ca2..85e98eca41d 100644 --- a/openlibrary/utils/tests/test_isbn.py +++ b/openlibrary/utils/tests/test_isbn.py @@ -1,12 +1,13 @@ import pytest + from openlibrary.utils.isbn import ( get_isbn_10_and_13, + get_isbn_10s_and_13s, isbn_10_to_isbn_13, isbn_13_to_isbn_10, normalize_identifier, normalize_isbn, opposite_isbn, - get_isbn_10s_and_13s, ) diff --git a/openlibrary/utils/tests/test_lccn.py b/openlibrary/utils/tests/test_lccn.py index 349214be12d..78eeac43e3f 100644 --- a/openlibrary/utils/tests/test_lccn.py +++ b/openlibrary/utils/tests/test_lccn.py @@ -1,4 +1,5 @@ import pytest + from openlibrary.utils.lccn import normalize_lccn diff --git a/openlibrary/utils/tests/test_processors.py b/openlibrary/utils/tests/test_processors.py index 82ffc32f6d5..c1bb2a7d8e6 100644 --- a/openlibrary/utils/tests/test_processors.py +++ b/openlibrary/utils/tests/test_processors.py @@ -1,6 +1,7 @@ -import web import time +import web + from ..processors import RateLimitProcessor diff --git a/openlibrary/utils/tests/test_retry.py b/openlibrary/utils/tests/test_retry.py index 2a4fc6f8b30..7fda9720e0a 100644 --- a/openlibrary/utils/tests/test_retry.py +++ b/openlibrary/utils/tests/test_retry.py @@ -1,5 +1,7 @@ from unittest.mock import Mock + import pytest + from openlibrary.utils.retry import MaxRetriesExceeded, RetryStrategy diff --git a/tests/test_docker_compose.py b/tests/test_docker_compose.py index 95830b0cf10..956944e9ec1 100644 --- a/tests/test_docker_compose.py +++ b/tests/test_docker_compose.py @@ -1,4 +1,5 @@ import os + import yaml