From e6df7c7b339de9a60bb6dab22e74a59263b16f68 Mon Sep 17 00:00:00 2001 From: RayBB Date: Tue, 5 Nov 2024 17:53:19 -0500 Subject: [PATCH] noqa all ol/infogami/web unused imports --- openlibrary/admin/numbers.py | 2 +- openlibrary/catalog/add_book/match.py | 2 +- openlibrary/conftest.py | 10 ++++++--- openlibrary/core/edits.py | 2 +- openlibrary/core/lists/model.py | 6 ++--- openlibrary/core/models.py | 7 ++++-- openlibrary/core/processors/__init__.py | 4 +++- openlibrary/coverstore/archive.py | 4 +++- openlibrary/coverstore/code.py | 4 ++-- openlibrary/data/sitemap.py | 4 +++- openlibrary/plugins/admin/code.py | 11 +++++++--- openlibrary/plugins/admin/mem.py | 2 +- openlibrary/plugins/admin/tests/test_code.py | 9 ++++++-- openlibrary/plugins/books/readlinks.py | 2 +- openlibrary/plugins/openlibrary/api.py | 22 ++++++++++++++----- .../plugins/openlibrary/borrow_home.py | 4 +++- openlibrary/plugins/openlibrary/code.py | 10 ++++++--- openlibrary/plugins/openlibrary/connection.py | 2 +- openlibrary/plugins/openlibrary/design.py | 7 ++++-- openlibrary/plugins/openlibrary/home.py | 2 +- openlibrary/plugins/openlibrary/lists.py | 5 ++++- openlibrary/plugins/openlibrary/processors.py | 12 ++++++---- openlibrary/plugins/openlibrary/stats.py | 2 +- openlibrary/plugins/openlibrary/utils.py | 2 +- openlibrary/plugins/upstream/account.py | 8 ++++--- openlibrary/plugins/upstream/addbook.py | 2 +- openlibrary/plugins/upstream/borrow.py | 8 +++++-- openlibrary/plugins/upstream/checkins.py | 4 +++- openlibrary/plugins/upstream/code.py | 11 ++++++---- openlibrary/plugins/upstream/data.py | 2 +- openlibrary/plugins/upstream/jsdef.py | 8 +++---- openlibrary/plugins/upstream/models.py | 10 +++++---- openlibrary/plugins/upstream/mybooks.py | 6 +++-- openlibrary/plugins/upstream/recentchanges.py | 4 +++- openlibrary/plugins/upstream/utils.py | 7 +++++- openlibrary/plugins/worksearch/bulk_search.py | 10 ++++++--- openlibrary/plugins/worksearch/languages.py | 2 +- openlibrary/plugins/worksearch/publishers.py | 7 ++++-- openlibrary/records/functions.py | 6 +++-- openlibrary/records/matchers.py | 4 ++-- openlibrary/utils/sentry.py | 6 ++++- pyproject.toml | 1 - scripts/delete_import_items.py | 6 +++-- scripts/import_pressbooks.py | 2 +- scripts/lc_marc_update.py | 2 +- scripts/oldump.py | 2 +- scripts/partner_batch_imports.py | 2 +- scripts/promise_batch_imports.py | 14 ++++++++---- scripts/pull-templates.py | 2 +- scripts/solr_updater.py | 2 +- scripts/store_counts.py | 2 +- scripts/update_stale_work_references.py | 4 ++-- 52 files changed, 187 insertions(+), 94 deletions(-) diff --git a/openlibrary/admin/numbers.py b/openlibrary/admin/numbers.py index b11692e696ce..4a98a31df0d3 100644 --- a/openlibrary/admin/numbers.py +++ b/openlibrary/admin/numbers.py @@ -22,7 +22,7 @@ import functools import logging -import web +import web # noqa: F401 side effects may be needed logger = logging.getLogger(__name__) diff --git a/openlibrary/catalog/add_book/match.py b/openlibrary/catalog/add_book/match.py index acc14b19b066..bcd665394eb7 100644 --- a/openlibrary/catalog/add_book/match.py +++ b/openlibrary/catalog/add_book/match.py @@ -1,6 +1,6 @@ import re import unicodedata -import web +import web # noqa: F401 side effects may be needed # fields needed for matching: # title, subtitle, isbn, publish_country, lccn, publishers, publish_date, number_of_pages, authors diff --git a/openlibrary/conftest.py b/openlibrary/conftest.py index e6747b67442d..c00dbc804a95 100644 --- a/openlibrary/conftest.py +++ b/openlibrary/conftest.py @@ -10,9 +10,13 @@ from openlibrary.i18n import gettext from openlibrary.core import helpers -from openlibrary.mocks.mock_infobase import mock_site -from openlibrary.mocks.mock_ia import mock_ia -from openlibrary.mocks.mock_memcache import mock_memcache +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 +) @pytest.fixture(autouse=True) diff --git a/openlibrary/core/edits.py b/openlibrary/core/edits.py index 1c9d40603e6c..26f7a39b72e8 100644 --- a/openlibrary/core/edits.py +++ b/openlibrary/core/edits.py @@ -1,6 +1,6 @@ import datetime import json -import web +import web # noqa: F401 side effects may be needed from sqlite3 import IntegrityError from psycopg2.errors import UniqueViolation diff --git a/openlibrary/core/lists/model.py b/openlibrary/core/lists/model.py index 5a82a3a65776..c4af01dce299 100644 --- a/openlibrary/core/lists/model.py +++ b/openlibrary/core/lists/model.py @@ -8,9 +8,9 @@ import web import logging -from infogami import config -from infogami.infobase import client, common -from infogami.utils import stats +from infogami import config # noqa: F401 side effects may be needed +from infogami.infobase import client, common # noqa: F401 side effects may be needed +from infogami.utils import stats # noqa: F401 side effects may be needed from openlibrary.core import helpers as h from openlibrary.core import cache diff --git a/openlibrary/core/models.py b/openlibrary/core/models.py index 277aca3fec02..d6d89174a099 100644 --- a/openlibrary/core/models.py +++ b/openlibrary/core/models.py @@ -19,7 +19,7 @@ # TODO: fix this. openlibrary.core should not import plugins. from openlibrary import accounts from openlibrary.core import lending -from openlibrary.catalog import add_book +from openlibrary.catalog import add_book # noqa: F401 side effects may be needed from openlibrary.core.booknotes import Booknotes from openlibrary.core.bookshelves import Bookshelves from openlibrary.core.follows import PubSub @@ -27,7 +27,10 @@ from openlibrary.core.imports import ImportItem from openlibrary.core.observations import Observations from openlibrary.core.ratings import Ratings -from openlibrary.utils import extract_numeric_id_from_olid, dateutil +from openlibrary.utils import ( + extract_numeric_id_from_olid, + dateutil, # noqa: F401 side effects may be needed +) from openlibrary.utils.isbn import to_isbn_13, isbn_13_to_isbn_10, canonical from openlibrary.core.wikidata import WikidataEntity, get_wikidata_entity diff --git a/openlibrary/core/processors/__init__.py b/openlibrary/core/processors/__init__.py index 01fd63f75c26..865ecbff643d 100644 --- a/openlibrary/core/processors/__init__.py +++ b/openlibrary/core/processors/__init__.py @@ -1 +1,3 @@ -from openlibrary.core.processors.readableurls import ReadableUrlProcessor +from openlibrary.core.processors.readableurls import ( + ReadableUrlProcessor, # noqa: F401 side effects may be needed +) diff --git a/openlibrary/coverstore/archive.py b/openlibrary/coverstore/archive.py index f65394f42efa..8797873444dd 100644 --- a/openlibrary/coverstore/archive.py +++ b/openlibrary/coverstore/archive.py @@ -13,7 +13,9 @@ from infogami.infobase import utils from openlibrary.coverstore import config, db -from openlibrary.coverstore.coverlib import find_image_path +from openlibrary.coverstore.coverlib import ( + find_image_path, # noqa: F401 side effects may be needed +) from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI diff --git a/openlibrary/coverstore/code.py b/openlibrary/coverstore/code.py index 895b0844ea13..c5c71ead3579 100644 --- a/openlibrary/coverstore/code.py +++ b/openlibrary/coverstore/code.py @@ -20,8 +20,8 @@ download, ol_get, ol_things, - random_string, - rm_f, + random_string, # noqa: F401 side effects may be needed + rm_f, # noqa: F401 side effects may be needed safeint, ) from openlibrary.plugins.openlibrary.processors import CORSProcessor diff --git a/openlibrary/data/sitemap.py b/openlibrary/data/sitemap.py index b0f92f173435..7fee370af657 100644 --- a/openlibrary/data/sitemap.py +++ b/openlibrary/data/sitemap.py @@ -19,7 +19,9 @@ import datetime from gzip import open as gzopen -from openlibrary.plugins.openlibrary.processors import urlsafe +from openlibrary.plugins.openlibrary.processors import ( + urlsafe, # noqa: F401 side effects may be needed +) t = web.template.Template diff --git a/openlibrary/plugins/admin/code.py b/openlibrary/plugins/admin/code.py index a804a893e40b..c97d91abd0a3 100644 --- a/openlibrary/plugins/admin/code.py +++ b/openlibrary/plugins/admin/code.py @@ -19,7 +19,7 @@ from infogami.utils.view import render, public from infogami.utils.context import context from infogami.utils.view import add_flash_message -from infogami.plugins.api.code import jsonapi +from infogami.plugins.api.code import jsonapi # noqa: F401 side effects may be needed from openlibrary.catalog.add_book import ( update_ia_metadata_for_ol_edition, @@ -31,7 +31,12 @@ from openlibrary import accounts from openlibrary.accounts.model import Account, clear_cookies from openlibrary.accounts.model import OpenLibraryAccount -from openlibrary.core import admin as admin_stats, helpers as h, imports, cache +from openlibrary.core import ( + admin as admin_stats, + helpers as h, # noqa: F401 side effects may be needed + imports, + cache, +) from openlibrary.core.models import Work from openlibrary.plugins.upstream import forms, spamcheck from openlibrary.plugins.upstream.account import send_forgot_password_email @@ -646,7 +651,7 @@ def g(docs): return storify(xstats) -from openlibrary.plugins.upstream import borrow +from openlibrary.plugins.upstream import borrow # noqa: F401 side effects may be needed class inspect: diff --git a/openlibrary/plugins/admin/mem.py b/openlibrary/plugins/admin/mem.py index f618da715773..5c1ff766c966 100644 --- a/openlibrary/plugins/admin/mem.py +++ b/openlibrary/plugins/admin/mem.py @@ -1,4 +1,4 @@ -from infogami.utils import delegate +from infogami.utils import delegate # noqa: F401 side effects may be needed from infogami.utils.view import render, safeint from openlibrary.plugins.admin import memory import web diff --git a/openlibrary/plugins/admin/tests/test_code.py b/openlibrary/plugins/admin/tests/test_code.py index bd75301c1a81..9a688c55de9a 100644 --- a/openlibrary/plugins/admin/tests/test_code.py +++ b/openlibrary/plugins/admin/tests/test_code.py @@ -1,9 +1,14 @@ from typing import cast -from openlibrary.accounts.model import Account, OpenLibraryAccount +from openlibrary.accounts.model import ( + Account, # noqa: F401 side effects may be needed + OpenLibraryAccount, +) from openlibrary.plugins.admin.code import revert_all_user_edits import web -from openlibrary.plugins.upstream.models import Changeset +from openlibrary.plugins.upstream.models import ( + Changeset, # noqa: F401 side effects may be needed +) def make_test_account(username: str) -> OpenLibraryAccount: diff --git a/openlibrary/plugins/books/readlinks.py b/openlibrary/plugins/books/readlinks.py index e66ab6abfc4c..071192d92733 100644 --- a/openlibrary/plugins/books/readlinks.py +++ b/openlibrary/plugins/books/readlinks.py @@ -10,7 +10,7 @@ import web from openlibrary.core import ia from openlibrary.core import helpers -from openlibrary.api import OpenLibrary +from openlibrary.api import OpenLibrary # noqa: F401 side effects may be needed from openlibrary.plugins.books import dynlinks from infogami.utils.delegate import register_exception from infogami.utils import stats diff --git a/openlibrary/plugins/openlibrary/api.py b/openlibrary/plugins/openlibrary/api.py index 299240efaa48..db2b6035b642 100644 --- a/openlibrary/plugins/openlibrary/api.py +++ b/openlibrary/plugins/openlibrary/api.py @@ -10,18 +10,30 @@ import io from collections import defaultdict from openlibrary.views.loanstats import get_trending_books -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from infogami.utils import delegate from infogami.utils.view import render_template # noqa: F401 used for its side effects from infogami.plugins.api.code import jsonapi -from infogami.utils.view import add_flash_message +from infogami.utils.view import ( + add_flash_message, # noqa: F401 side effects may be needed +) from openlibrary import accounts from openlibrary.plugins.openlibrary.code import can_write from openlibrary.utils import extract_numeric_id_from_olid from openlibrary.utils.isbn import isbn_10_to_isbn_13, normalize_isbn -from openlibrary.plugins.worksearch.subjects import get_subject -from openlibrary.accounts.model import OpenLibraryAccount -from openlibrary.core import ia, db, models, lending, helpers as h +from openlibrary.plugins.worksearch.subjects import ( + get_subject, # noqa: F401 side effects may be needed +) +from openlibrary.accounts.model import ( + OpenLibraryAccount, # noqa: F401 side effects may be needed +) +from openlibrary.core import ( + ia, # noqa: F401 side effects may be needed + db, # noqa: F401 side effects may be needed + models, + lending, + helpers as h, +) from openlibrary.core.bookshelves_events import BookshelvesEvents from openlibrary.core.observations import Observations, get_observation_metrics from openlibrary.core.models import Booknotes, Work diff --git a/openlibrary/plugins/openlibrary/borrow_home.py b/openlibrary/plugins/openlibrary/borrow_home.py index f1d02d5504b8..1e5a0fb2dba0 100644 --- a/openlibrary/plugins/openlibrary/borrow_home.py +++ b/openlibrary/plugins/openlibrary/borrow_home.py @@ -13,7 +13,9 @@ import eventer from infogami.utils import delegate -from infogami.utils.view import render_template # used for its side effects +from infogami.utils.view import ( + render_template, # noqa: F401 side effects may be needed +) # used for its side effects # noqa: F401 side effects may be needed from openlibrary.core import statsdb diff --git a/openlibrary/plugins/openlibrary/code.py b/openlibrary/plugins/openlibrary/code.py index f62414ed2088..2d65f684b107 100644 --- a/openlibrary/plugins/openlibrary/code.py +++ b/openlibrary/plugins/openlibrary/code.py @@ -38,7 +38,9 @@ from infogami.core.db import ValidationException from openlibrary.core import cache -from openlibrary.core.vendors import create_edition_from_amazon_metadata +from openlibrary.core.vendors import ( + create_edition_from_amazon_metadata, # noqa: F401 side effects may be needed +) from openlibrary.utils.isbn import isbn_13_to_isbn_10, isbn_10_to_isbn_13, canonical from openlibrary.core.models import Edition from openlibrary.core.lending import get_availability @@ -298,7 +300,7 @@ def POST(self): class clonebook(delegate.page): def GET(self): - from infogami.core.code import edit + from infogami.core.code import edit # noqa: F401 side effects may be needed i = web.input('key') page = web.ctx.site.get(i.key) @@ -1406,7 +1408,9 @@ def setup(): authors.setup() swagger.setup() - from openlibrary.plugins.openlibrary import api + from openlibrary.plugins.openlibrary import ( + api, # noqa: F401 side effects may be needed + ) delegate.app.add_processor(web.unloadhook(stats.stats_hook)) diff --git a/openlibrary/plugins/openlibrary/connection.py b/openlibrary/plugins/openlibrary/connection.py index d05acc3aaf7e..a147b3040110 100644 --- a/openlibrary/plugins/openlibrary/connection.py +++ b/openlibrary/plugins/openlibrary/connection.py @@ -2,7 +2,7 @@ """ from infogami import config -from infogami.infobase import client, lru +from infogami.infobase import client, lru # noqa: F401 side effects may be needed from infogami.utils import stats import web diff --git a/openlibrary/plugins/openlibrary/design.py b/openlibrary/plugins/openlibrary/design.py index 71c67a5aa25b..4380704fb209 100644 --- a/openlibrary/plugins/openlibrary/design.py +++ b/openlibrary/plugins/openlibrary/design.py @@ -1,8 +1,11 @@ -import web +import web # noqa: F401 side effects may be needed import logging from infogami.utils import delegate -from infogami.utils.view import render_template, public +from infogami.utils.view import ( + render_template, + public, # noqa: F401 side effects may be needed +) logger = logging.getLogger("openlibrary.design") diff --git a/openlibrary/plugins/openlibrary/home.py b/openlibrary/plugins/openlibrary/home.py index b2bca58ee28a..54dc223584c4 100644 --- a/openlibrary/plugins/openlibrary/home.py +++ b/openlibrary/plugins/openlibrary/home.py @@ -8,7 +8,7 @@ from infogami.utils import delegate from infogami.utils.view import render_template, public from infogami.infobase.client import storify -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from openlibrary.core import admin, cache, ia, lending from openlibrary.i18n import gettext as _ diff --git a/openlibrary/plugins/openlibrary/lists.py b/openlibrary/plugins/openlibrary/lists.py index 86dd09b79187..d995a1cc1e05 100644 --- a/openlibrary/plugins/openlibrary/lists.py +++ b/openlibrary/plugins/openlibrary/lists.py @@ -24,7 +24,10 @@ import openlibrary.core.helpers as h from openlibrary.i18n import gettext as _ from openlibrary.plugins.upstream.addbook import safe_seeother -from openlibrary.utils import dateutil, olid_to_key +from openlibrary.utils import ( + dateutil, # noqa: F401 side effects may be needed + olid_to_key, +) from openlibrary.plugins.upstream import spamcheck, utils from openlibrary.plugins.upstream.account import MyBooksTemplate from openlibrary.plugins.worksearch import subjects diff --git a/openlibrary/plugins/openlibrary/processors.py b/openlibrary/plugins/openlibrary/processors.py index a304b1324676..cd19970eff16 100644 --- a/openlibrary/plugins/openlibrary/processors.py +++ b/openlibrary/plugins/openlibrary/processors.py @@ -5,10 +5,14 @@ import web from openlibrary.accounts import get_current_user -from openlibrary.core import cache -from openlibrary.core.processors import ReadableUrlProcessor -from openlibrary.plugins.openlibrary.home import caching_prethread -from openlibrary.utils import dateutil +from openlibrary.core import cache # noqa: F401 side effects may be needed +from openlibrary.core.processors import ( + ReadableUrlProcessor, # noqa: F401 side effects may be needed +) +from openlibrary.plugins.openlibrary.home import ( + caching_prethread, # noqa: F401 side effects may be needed +) +from openlibrary.utils import dateutil # noqa: F401 side effects may be needed from openlibrary.core import helpers as h diff --git a/openlibrary/plugins/openlibrary/stats.py b/openlibrary/plugins/openlibrary/stats.py index effe7d5e3acb..1b7f57ecc0b5 100644 --- a/openlibrary/plugins/openlibrary/stats.py +++ b/openlibrary/plugins/openlibrary/stats.py @@ -14,7 +14,7 @@ from openlibrary.core import stats as graphite_stats import web from infogami import config -from infogami.utils import delegate, stats +from infogami.utils import delegate, stats # noqa: F401 side effects may be needed import openlibrary.plugins.openlibrary.filters as stats_filters diff --git a/openlibrary/plugins/openlibrary/utils.py b/openlibrary/plugins/openlibrary/utils.py index 79be1b0b2dde..6eb36ed6e312 100644 --- a/openlibrary/plugins/openlibrary/utils.py +++ b/openlibrary/plugins/openlibrary/utils.py @@ -1 +1 @@ -from openlibrary.core.helpers import sanitize +from openlibrary.core.helpers import sanitize # noqa: F401 side effects may be needed diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py index 7aa7b3057f22..9593aa5c4670 100644 --- a/openlibrary/plugins/upstream/account.py +++ b/openlibrary/plugins/upstream/account.py @@ -18,7 +18,7 @@ add_flash_message, ) from infogami.infobase.client import ClientException -import infogami.core.code as core +import infogami.core.code as core # noqa: F401 side effects may be needed from openlibrary import accounts from openlibrary.i18n import gettext as _ @@ -39,7 +39,7 @@ from openlibrary.plugins import openlibrary as olib from openlibrary.accounts import ( audit_accounts, - Account, + Account, # noqa: F401 side effects may be needed OpenLibraryAccount, InternetArchiveAccount, valid_email, @@ -348,7 +348,9 @@ def POST(self): payload is json. Instead, if login attempted w/ json credentials, requires Archive.org s3 keys. """ - from openlibrary.plugins.openlibrary.code import BadRequest + from openlibrary.plugins.openlibrary.code import ( + BadRequest, # noqa: F401 side effects may be needed + ) d = json.loads(web.data()) email = d.get('email', "") diff --git a/openlibrary/plugins/upstream/addbook.py b/openlibrary/plugins/upstream/addbook.py index dc80bb957a09..7515eb1aa1d9 100644 --- a/openlibrary/plugins/upstream/addbook.py +++ b/openlibrary/plugins/upstream/addbook.py @@ -16,7 +16,7 @@ from openlibrary.plugins.worksearch.search import get_solr from openlibrary.core.helpers import uniq -from openlibrary.i18n import gettext as _ +from openlibrary.i18n import gettext as _ # noqa: F401 side effects may be needed from openlibrary import accounts import logging diff --git a/openlibrary/plugins/upstream/borrow.py b/openlibrary/plugins/upstream/borrow.py index 5f54e07128c7..b6598e23519f 100644 --- a/openlibrary/plugins/upstream/borrow.py +++ b/openlibrary/plugins/upstream/borrow.py @@ -15,10 +15,14 @@ from infogami import config from infogami.utils import delegate -from infogami.utils.view import public, render_template, add_flash_message +from infogami.utils.view import ( + public, + render_template, # noqa: F401 side effects may be needed + add_flash_message, +) from infogami.infobase.utils import parse_datetime -from openlibrary.core import models +from openlibrary.core import models # noqa: F401 side effects may be needed from openlibrary.core import stats from openlibrary.core import lending from openlibrary.core import vendors diff --git a/openlibrary/plugins/upstream/checkins.py b/openlibrary/plugins/upstream/checkins.py index 9bc5aa5d4562..3a57b51ad232 100644 --- a/openlibrary/plugins/upstream/checkins.py +++ b/openlibrary/plugins/upstream/checkins.py @@ -15,7 +15,9 @@ from openlibrary.core.yearly_reading_goals import YearlyReadingGoals from openlibrary.utils import extract_numeric_id_from_olid from openlibrary.core.bookshelves_events import BookshelfEvent, BookshelvesEvents -from openlibrary.utils.decorators import authorized_for +from openlibrary.utils.decorators import ( + authorized_for, # noqa: F401 side effects may be needed +) MAX_READING_GOAL = 10_000 diff --git a/openlibrary/plugins/upstream/code.py b/openlibrary/plugins/upstream/code.py index 131445b84eb0..3accbcdfe6a3 100644 --- a/openlibrary/plugins/upstream/code.py +++ b/openlibrary/plugins/upstream/code.py @@ -14,19 +14,22 @@ from infogami.plugins.api.code import request as infogami_request from infogami.infobase import client -from infogami.utils import delegate, app, types +from infogami.utils import delegate, app, types # noqa: F401 side effects may be needed from infogami.utils.view import public, safeint, render from infogami.utils.view import render_template # used for its side effects -from infogami.utils.context import context +from infogami.utils.context import context # noqa: F401 side effects may be needed -from openlibrary import accounts +from openlibrary import accounts # noqa: F401 side effects may be needed from openlibrary.plugins.upstream import addbook, addtag, covers, models, utils from openlibrary.plugins.upstream import spamcheck from openlibrary.plugins.upstream import merge_authors from openlibrary.plugins.upstream import edits from openlibrary.plugins.upstream import checkins -from openlibrary.plugins.upstream import borrow, recentchanges # TODO: unused imports? +from openlibrary.plugins.upstream import ( + borrow, # noqa: F401 side effects may be needed + recentchanges, # noqa: F401 side effects may be needed +) # TODO: unused imports? # noqa: F401 side effects may be needed from openlibrary.plugins.upstream.utils import render_component if not config.get('coverstore_url'): diff --git a/openlibrary/plugins/upstream/data.py b/openlibrary/plugins/upstream/data.py index 1d494ce0b667..d9e66b876cd5 100644 --- a/openlibrary/plugins/upstream/data.py +++ b/openlibrary/plugins/upstream/data.py @@ -4,7 +4,7 @@ import web from infogami import config from infogami.utils import delegate -from infogami.utils.view import public +from infogami.utils.view import public # noqa: F401 side effects may be needed import requests diff --git a/openlibrary/plugins/upstream/jsdef.py b/openlibrary/plugins/upstream/jsdef.py index 2c5978b7efff..ab13ae555ec6 100644 --- a/openlibrary/plugins/upstream/jsdef.py +++ b/openlibrary/plugins/upstream/jsdef.py @@ -57,10 +57,10 @@ import web from web.template import ( - Template, - Parser, - LineNode, - SuiteNode, + Template, # noqa: F401 side effects may be needed + Parser, # noqa: F401 side effects may be needed + LineNode, # noqa: F401 side effects may be needed + SuiteNode, # noqa: F401 side effects may be needed DefNode, PythonTokenizer, # INDENT, diff --git a/openlibrary/plugins/upstream/models.py b/openlibrary/plugins/upstream/models.py index 9e9d40a4bdba..93b7c39441fe 100644 --- a/openlibrary/plugins/upstream/models.py +++ b/openlibrary/plugins/upstream/models.py @@ -8,9 +8,9 @@ from collections import defaultdict from isbnlib import canonical, mask, NotValidISBNError -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from infogami.infobase import client -from infogami.utils.view import safeint +from infogami.utils.view import safeint # noqa: F401 side effects may be needed from infogami.utils import stats from openlibrary.core import models, ia @@ -19,12 +19,14 @@ from openlibrary.plugins.upstream.table_of_contents import TableOfContents from openlibrary.plugins.upstream.utils import MultiDict, get_edition_config -from openlibrary.plugins.upstream import account +from openlibrary.plugins.upstream import ( + account, # noqa: F401 side effects may be needed +) from openlibrary.plugins.upstream import borrow from openlibrary.plugins.worksearch.code import works_by_author from openlibrary.plugins.worksearch.search import get_solr -from openlibrary.utils import dateutil +from openlibrary.utils import dateutil # noqa: F401 side effects may be needed from openlibrary.utils.isbn import isbn_10_to_isbn_13, isbn_13_to_isbn_10 from openlibrary.utils.lccn import normalize_lccn diff --git a/openlibrary/plugins/upstream/mybooks.py b/openlibrary/plugins/upstream/mybooks.py index 9ac39f180a35..be042f115053 100644 --- a/openlibrary/plugins/upstream/mybooks.py +++ b/openlibrary/plugins/upstream/mybooks.py @@ -4,14 +4,16 @@ from typing import Final, Literal, cast, TYPE_CHECKING -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from infogami.utils import delegate from infogami.utils.view import public, safeint, render from openlibrary.i18n import gettext as _ from openlibrary import accounts -from openlibrary.accounts.model import OpenLibraryAccount +from openlibrary.accounts.model import ( + OpenLibraryAccount, # noqa: F401 side effects may be needed +) from openlibrary.utils import extract_numeric_id_from_olid from openlibrary.utils.dateutil import current_year from openlibrary.core.booknotes import Booknotes diff --git a/openlibrary/plugins/upstream/recentchanges.py b/openlibrary/plugins/upstream/recentchanges.py index 6db3ff83d9e5..c6ced44e73ae 100644 --- a/openlibrary/plugins/upstream/recentchanges.py +++ b/openlibrary/plugins/upstream/recentchanges.py @@ -9,7 +9,9 @@ from infogami.utils import delegate from infogami.utils.view import public, render, render_template, safeint -from infogami.utils.view import add_flash_message # TODO: unused import? +from infogami.utils.view import ( + add_flash_message, # noqa: F401 side effects may be needed +) # TODO: unused import? # noqa: F401 side effects may be needed from infogami.utils import features from openlibrary.utils import dateutil diff --git a/openlibrary/plugins/upstream/utils.py b/openlibrary/plugins/upstream/utils.py index 71bdf2ce0634..ffb52b8516ef 100644 --- a/openlibrary/plugins/upstream/utils.py +++ b/openlibrary/plugins/upstream/utils.py @@ -32,7 +32,12 @@ from infogami import config from infogami.utils import view, delegate, stats -from infogami.utils.view import render, get_template, public, query_param +from infogami.utils.view import ( + render, + get_template, + public, + query_param, # noqa: F401 side effects may be needed +) from infogami.utils.macro import macro from infogami.utils.context import InfogamiContext, context from infogami.infobase.client import Changeset, Nothing, Thing, storify diff --git a/openlibrary/plugins/worksearch/bulk_search.py b/openlibrary/plugins/worksearch/bulk_search.py index 93f702f1d5c4..3e6eb365a54d 100644 --- a/openlibrary/plugins/worksearch/bulk_search.py +++ b/openlibrary/plugins/worksearch/bulk_search.py @@ -1,8 +1,12 @@ -import web +import web # noqa: F401 side effects may be needed -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from infogami.utils import delegate -from infogami.utils.view import public, safeint, render +from infogami.utils.view import ( + public, # noqa: F401 side effects may be needed + safeint, # noqa: F401 side effects may be needed + render, +) class bulk_search(delegate.page): diff --git a/openlibrary/plugins/worksearch/languages.py b/openlibrary/plugins/worksearch/languages.py index 3a5a89dffbca..8261a3a9e998 100644 --- a/openlibrary/plugins/worksearch/languages.py +++ b/openlibrary/plugins/worksearch/languages.py @@ -2,7 +2,7 @@ """ from infogami.plugins.api.code import jsonapi -from infogami.utils import delegate, stats +from infogami.utils import delegate, stats # noqa: F401 side effects may be needed from infogami.utils.view import render_template, safeint import web import json diff --git a/openlibrary/plugins/worksearch/publishers.py b/openlibrary/plugins/worksearch/publishers.py index 44f62a214094..7fa6fa438875 100644 --- a/openlibrary/plugins/worksearch/publishers.py +++ b/openlibrary/plugins/worksearch/publishers.py @@ -1,8 +1,11 @@ """Publisher pages """ -from infogami.utils import delegate, stats -from infogami.utils.view import render_template, safeint +from infogami.utils import delegate, stats # noqa: F401 side effects may be needed +from infogami.utils.view import ( + render_template, + safeint, # noqa: F401 side effects may be needed +) import web import logging diff --git a/openlibrary/records/functions.py b/openlibrary/records/functions.py index 395ff52c604c..fab18bc68f49 100644 --- a/openlibrary/records/functions.py +++ b/openlibrary/records/functions.py @@ -7,9 +7,11 @@ import web -from openlibrary.catalog.add_book import normalize +from openlibrary.catalog.add_book import ( + normalize, # noqa: F401 side effects may be needed +) from openlibrary.core.models import Thing -import openlibrary.core.helpers as h +import openlibrary.core.helpers as h # noqa: F401 side effects may be needed class NoQueryParam(KeyError): diff --git a/openlibrary/records/matchers.py b/openlibrary/records/matchers.py index 57e544a58553..a5b70123d932 100644 --- a/openlibrary/records/matchers.py +++ b/openlibrary/records/matchers.py @@ -23,8 +23,8 @@ from collections import defaultdict import logging as Logging -from infogami import config -from openlibrary.utils.solr import Solr +from infogami import config # noqa: F401 side effects may be needed +from openlibrary.utils.solr import Solr # noqa: F401 side effects may be needed import web diff --git a/openlibrary/utils/sentry.py b/openlibrary/utils/sentry.py index f1f20978cb26..b6959c4dc3cf 100644 --- a/openlibrary/utils/sentry.py +++ b/openlibrary/utils/sentry.py @@ -6,7 +6,11 @@ import web from sentry_sdk.utils import capture_internal_exceptions from sentry_sdk.tracing import Transaction, TRANSACTION_SOURCE_ROUTE -from infogami.utils.app import find_page, find_view, modes +from infogami.utils.app import ( + find_page, + find_view, # noqa: F401 side effects may be needed + modes, +) from infogami.utils.types import type_patterns from openlibrary.utils import get_software_version diff --git a/pyproject.toml b/pyproject.toml index 5a2f36d04dc7..c2ea6f53fe20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,6 @@ ignore = [ "B904", "B905", "E402", - "F401", "F841", "I", "PERF401", diff --git a/scripts/delete_import_items.py b/scripts/delete_import_items.py index 1a2f3e3563a6..e0bdd2eec669 100644 --- a/scripts/delete_import_items.py +++ b/scripts/delete_import_items.py @@ -21,11 +21,13 @@ from configparser import ConfigParser from pathlib import Path -import _init_path # Imported for its side effect of setting PYTHONPATH +import _init_path # Imported for its side effect of setting PYTHONPATH # noqa: F401 side effects may be needed from openlibrary.config import load_config from openlibrary.core.imports import ImportItem -from openlibrary.core.edits import CommunityEditsQueue +from openlibrary.core.edits import ( + CommunityEditsQueue, # noqa: F401 side effects may be needed +) class DeleteImportItemJob: diff --git a/scripts/import_pressbooks.py b/scripts/import_pressbooks.py index 5316982d102d..0587c3c691bf 100644 --- a/scripts/import_pressbooks.py +++ b/scripts/import_pressbooks.py @@ -10,7 +10,7 @@ import requests import html -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from openlibrary.config import load_config from openlibrary.core.imports import Batch from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI diff --git a/scripts/lc_marc_update.py b/scripts/lc_marc_update.py index 672d823fa8ef..402248343d13 100755 --- a/scripts/lc_marc_update.py +++ b/scripts/lc_marc_update.py @@ -1,7 +1,7 @@ #!/usr/bin/env python from openlibrary.catalog.importer.scribe import BadImport -from openlibrary.catalog.read_rc import read_rc +from openlibrary.catalog.read_rc import read_rc # noqa: F401 side effects may be needed from openlibrary import config from ftplib import FTP from time import sleep diff --git a/scripts/oldump.py b/scripts/oldump.py index b4a9978a2ea6..555e5db80247 100755 --- a/scripts/oldump.py +++ b/scripts/oldump.py @@ -5,7 +5,7 @@ import sys from datetime import datetime -import _init_path # Imported for its side effect of setting PYTHONPATH +import _init_path # Imported for its side effect of setting PYTHONPATH # noqa: F401 side effects may be needed logger = logging.getLogger(__file__) logger.setLevel(logging.DEBUG) diff --git a/scripts/partner_batch_imports.py b/scripts/partner_batch_imports.py index 82127376330c..d010aefb7bcf 100755 --- a/scripts/partner_batch_imports.py +++ b/scripts/partner_batch_imports.py @@ -19,7 +19,7 @@ import requests -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from openlibrary.config import load_config from openlibrary.core.imports import Batch from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI diff --git a/scripts/promise_batch_imports.py b/scripts/promise_batch_imports.py index 8702ab0de814..5a28ff1fc88f 100644 --- a/scripts/promise_batch_imports.py +++ b/scripts/promise_batch_imports.py @@ -24,12 +24,18 @@ from typing import Any from urllib.parse import urlencode -import _init_path # Imported for its side effect of setting PYTHONPATH -from infogami import config +import _init_path # Imported for its side effect of setting PYTHONPATH # noqa: F401 side effects may be needed +from infogami import config # noqa: F401 side effects may be needed from openlibrary.config import load_config from openlibrary.core import stats -from openlibrary.core.imports import Batch, ImportItem -from openlibrary.core.vendors import get_amazon_metadata, stage_bookworm_metadata +from openlibrary.core.imports import ( + Batch, + ImportItem, # noqa: F401 side effects may be needed +) +from openlibrary.core.vendors import ( + get_amazon_metadata, # noqa: F401 side effects may be needed + stage_bookworm_metadata, +) from openlibrary.plugins.upstream.utils import safeget from openlibrary.utils.isbn import to_isbn_13 from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI diff --git a/scripts/pull-templates.py b/scripts/pull-templates.py index 97533ea1f492..58c4d556ef6c 100755 --- a/scripts/pull-templates.py +++ b/scripts/pull-templates.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """Script to pull templates and macros from an openlibrary instance to repository. """ -import _init_path # Imported for its side effect of setting PYTHONPATH +import _init_path # Imported for its side effect of setting PYTHONPATH # noqa: F401 side effects may be needed import os import web diff --git a/scripts/solr_updater.py b/scripts/solr_updater.py index 961727255a54..37fb822bedd6 100644 --- a/scripts/solr_updater.py +++ b/scripts/solr_updater.py @@ -19,7 +19,7 @@ from collections.abc import Iterator -import _init_path # Imported for its side effect of setting PYTHONPATH +import _init_path # Imported for its side effect of setting PYTHONPATH # noqa: F401 side effects may be needed import aiofiles import web diff --git a/scripts/store_counts.py b/scripts/store_counts.py index ea946a2bf831..658c8514b259 100755 --- a/scripts/store_counts.py +++ b/scripts/store_counts.py @@ -2,7 +2,7 @@ import sys -import _init_path # Imported for its side effect of setting PYTHONPATH +import _init_path # Imported for its side effect of setting PYTHONPATH # noqa: F401 side effects may be needed from openlibrary.admin import stats diff --git a/scripts/update_stale_work_references.py b/scripts/update_stale_work_references.py index 4eba6544abac..d8f0341bb8e7 100644 --- a/scripts/update_stale_work_references.py +++ b/scripts/update_stale_work_references.py @@ -2,9 +2,9 @@ PYTHONPATH=. python ./scripts/update_stale_work_references.py /olsystem/etc/openlibrary.yml """ -import web +import web # noqa: F401 side effects may be needed import infogami -from infogami import config +from infogami import config # noqa: F401 side effects may be needed from openlibrary.config import load_config from openlibrary.core.models import Work from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI