Skip to content

Commit

Permalink
noqa all ol/infogami/web unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
RayBB committed Nov 5, 2024
1 parent 418d39d commit e6df7c7
Show file tree
Hide file tree
Showing 52 changed files with 187 additions and 94 deletions.
2 changes: 1 addition & 1 deletion openlibrary/admin/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import functools
import logging

import web
import web # noqa: F401 side effects may be needed

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/match.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 7 additions & 3 deletions openlibrary/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/edits.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions openlibrary/core/lists/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions openlibrary/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@
# 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
from openlibrary.core.helpers import private_collection_in
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

Expand Down
4 changes: 3 additions & 1 deletion openlibrary/core/processors/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from openlibrary.core.processors.readableurls import ReadableUrlProcessor
from openlibrary.core.processors.readableurls import (
ReadableUrlProcessor, # noqa: F401 side effects may be needed
)
4 changes: 3 additions & 1 deletion openlibrary/coverstore/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions openlibrary/coverstore/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion openlibrary/data/sitemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions openlibrary/plugins/admin/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/admin/mem.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions openlibrary/plugins/admin/tests/test_code.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/books/readlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 17 additions & 5 deletions openlibrary/plugins/openlibrary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion openlibrary/plugins/openlibrary/borrow_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions openlibrary/plugins/openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/openlibrary/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions openlibrary/plugins/openlibrary/design.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/openlibrary/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down
5 changes: 4 additions & 1 deletion openlibrary/plugins/openlibrary/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions openlibrary/plugins/openlibrary/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/openlibrary/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/openlibrary/utils.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from openlibrary.core.helpers import sanitize
from openlibrary.core.helpers import sanitize # noqa: F401 side effects may be needed
8 changes: 5 additions & 3 deletions openlibrary/plugins/upstream/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand All @@ -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,
Expand Down Expand Up @@ -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', "")
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/upstream/addbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions openlibrary/plugins/upstream/borrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion openlibrary/plugins/upstream/checkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit e6df7c7

Please sign in to comment.