Skip to content

Commit

Permalink
Revert "internetarchive#10196 Removed redundant # noqa comments"
Browse files Browse the repository at this point in the history
This reverts commit 0e51e9c.
  • Loading branch information
drona-gyawali committed Dec 27, 2024
1 parent 9426e29 commit 6f7e4f6
Show file tree
Hide file tree
Showing 246 changed files with 447 additions and 319 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report! 👍
Thanks for taking the time to fill out this bug report! 👍
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ module.exports = {
"addons": [
"@storybook/addon-essentials"
],
}
}
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
}
}
2 changes: 1 addition & 1 deletion conf/solr/conf/wordtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
# "copyright" symbol (©), see https://github.com/internetarchive/openlibrary/issues/7555
\u00A9 => ALPHANUM
# number sign (#), only as alphabetic for case like 'C#'
\u0023 => ALPHA
\u0023 => ALPHA
2 changes: 1 addition & 1 deletion openlibrary/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# FIXME: several modules import things from accounts.model
# directly through openlibrary.accounts
from .model import *
from .model import * # noqa: F403
from .model import Account, Link

if TYPE_CHECKING:
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/accounts/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import requests
import web
from validate_email import validate_email

from infogami import config
from infogami.infobase.client import ClientException
from infogami.utils.view import public, render_template
from validate_email import validate_email

from openlibrary.core import helpers, stats
from openlibrary.core.booknotes import Booknotes
from openlibrary.core.bookshelves import Bookshelves
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/admin/code.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

import web
from infogami.utils.view import render_template

from infogami.utils.view import render_template
from openlibrary.admin import utils
from openlibrary.core import admin

Expand Down
1 change: 1 addition & 0 deletions openlibrary/admin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""

import web

from infogami.utils import delegate, features
from infogami.utils.view import render_template

Expand Down
3 changes: 2 additions & 1 deletion openlibrary/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Utilities to build the app.
"""

from web.template import TemplateResult

from infogami.utils import app as _app
from infogami.utils.macro import macro
from infogami.utils.view import public, render
from web.template import TemplateResult


class view(_app.page):
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/book_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,4 +705,4 @@ def get_solr_keys() -> list[str]:
return [p.solr_key for p in PROVIDER_ORDER if p.solr_key]


get_book_provider.ia = get_book_provider_by_name("ia")
setattr(get_book_provider, 'ia', get_book_provider_by_name('ia')) # noqa: B010
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

import requests
import web
from infogami import config

from infogami import config
from openlibrary import accounts
from openlibrary.catalog.add_book.load_book import (
InvalidLanguage,
Expand Down
6 changes: 3 additions & 3 deletions openlibrary/catalog/add_book/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ def compare_authors(e1: dict, e2: dict):
:rtype: tuple
:return: str?, message, score
"""
if 'authors' in e1 and 'authors' in e2:
if 'authors' in e1 and 'authors' in e2: # noqa: SIM102
if compare_author_fields(e1['authors'], e2['authors']):
return ('authors', 'exact match', 125)

if 'authors' in e1 and 'contribs' in e2:
if 'authors' in e1 and 'contribs' in e2: # noqa: SIM102
if compare_author_fields(e1['authors'], e2['contribs']):
return ('authors', 'exact match', 125)

if 'contribs' in e1 and 'authors' in e2:
if 'contribs' in e1 and 'authors' in e2: # noqa: SIM102
if compare_author_fields(e1['contribs'], e2['authors']):
return ('authors', 'exact match', 125)

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/tests/test_add_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from datetime import datetime

import pytest

from infogami.infobase.client import Nothing
from infogami.infobase.core import Text

from openlibrary.catalog import add_book
from openlibrary.catalog.add_book import (
IndependentlyPublished,
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/get_ia.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import lxml.etree
import requests
from infogami import config
from lxml import etree

from infogami import config
from openlibrary.catalog.marc.marc_binary import MarcBinary
from openlibrary.catalog.marc.marc_xml import MarcXml
from openlibrary.core import ia
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/marc/marc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_control(self, tag: str) -> str | None:
control = self.read_fields([tag])
_, v = next(control, (tag, None))
assert isinstance(v, (str, type(None)))
if tag == '008' and v:
if tag == '008' and v: # noqa: SIM102
# Handle duplicate 008s, even though control fields are non-repeatable.
if others := [str(d) for _, d in list(control) if len(str(d)) == 40]:
return min(others + [v], key=lambda s: s.count(' '))
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/marc/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def read_author_person(field: MarcFieldBase, tag: str = '100') -> dict | None:
author[field_name] = name_from_list(contents[subfield])
if 'q' in contents:
author['fuller_name'] = ' '.join(contents['q'])
if '6' in contents:
if '6' in contents: # noqa: SIM102 - alternate script name exists
if (link := field.rec.get_linkage(tag, contents['6'][0])) and (
alt_name := link.get_subfield_values('a')
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
"publish_places": [
"Washington"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"Description and travel",
"History"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
"publish_places": [
"New York"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"publish_places": [
"San Francisco?"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"publish_places": [
"London"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@
"oclc_numbers": [
"232977651"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
"Regimental histories",
"History"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
<subfield code="m">Hebr</subfield>
<subfield code="w">PREM</subfield>
</datafield>
</record>
</record>
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@
<datafield tag="MDM" ind1="9" ind2=" ">
<subfield code="a">Multiple digitized volumes exist for this title--see holdings for URLs</subfield>
</datafield>
</record>
</record>
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@
<subfield code="d">20070405</subfield>
</datafield>
</record>
</collection>
</collection>
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
<subfield code="h">S599.I7A3</subfield>
<subfield code="w">SERLOC</subfield>
</datafield>
</record>
</record>
2 changes: 2 additions & 0 deletions openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def setup():
load_views()

# load actions
from . import actions # noqa: F401 side effects may be needed

logger.info("loading complete.")

Expand All @@ -63,6 +64,7 @@ def setup_logging():

def load_views():
"""Registers all views by loading all view modules."""
from .views import showmarc # noqa: F401 side effects may be needed


setup()
2 changes: 1 addition & 1 deletion openlibrary/components/LibraryExplorer/ddc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6739,4 +6739,4 @@
],
"count": 645745
}
]
]
2 changes: 1 addition & 1 deletion openlibrary/components/LibraryExplorer/lcc.json
Original file line number Diff line number Diff line change
Expand Up @@ -1547,4 +1547,4 @@
],
"count": 177625
}
]
]
3 changes: 2 additions & 1 deletion openlibrary/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import os
import sys

import infogami
import yaml

import infogami
from infogami import config
from infogami.infobase import server

Expand Down
9 changes: 8 additions & 1 deletion openlibrary/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@

import pytest
import web

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.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_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/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import requests
import web
from infogami import config

from infogami import config
from openlibrary.core import cache


Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/bookshelves.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Any, Final, Literal, TypedDict, cast

import web
from infogami.infobase.utils import flatten

from infogami.infobase.utils import flatten
from openlibrary.plugins.worksearch.search import get_solr
from openlibrary.utils.dateutil import DATE_ONE_MONTH_AGO, DATE_ONE_WEEK_AGO

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

import memcache
import web

from infogami import config
from infogami.infobase.client import Nothing
from infogami.utils import stats

from openlibrary.core.helpers import NothingEncoder
from openlibrary.utils import olmemcache
from openlibrary.utils.dateutil import MINUTE_SECS
Expand Down
3 changes: 2 additions & 1 deletion openlibrary/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from sqlite3 import IntegrityError

import web
from infogami.utils import stats
from psycopg2.errors import UniqueViolation

from infogami.utils import stats


@web.memoize
def _get_db():
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import json
from sqlite3 import IntegrityError

from infogami.utils.view import public
from psycopg2.errors import UniqueViolation

from infogami.utils.view import public
from openlibrary.core import cache
from openlibrary.i18n import gettext as _
from openlibrary.utils import dateutil
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/core/fulltext.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import requests
import web
from infogami import config

from infogami import config
from openlibrary.core.lending import get_availability_of_ocaids
from openlibrary.plugins.openlibrary.home import format_book_data

Expand Down
6 changes: 4 additions & 2 deletions openlibrary/core/ia.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import requests
import web

from infogami import config
from infogami.utils import stats

from openlibrary.core import cache

logger = logging.getLogger('openlibrary.ia')
Expand Down Expand Up @@ -309,7 +309,9 @@ def get_candidates_url(
'!noindex:true',
]
)
exempt_collections = ' OR '.join(["collection:thoth-archiving-network"])
exempt_collections = ' OR '.join( # noqa: FLY002
["collection:thoth-archiving-network"]
)
params = {
'q': f'({hard_requirements}) AND (({soft_requirements}) OR ({exempt_collections}))',
'fl': 'identifier,format',
Expand Down
Loading

0 comments on commit 6f7e4f6

Please sign in to comment.