Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (internetarchive#9694)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.5.5 → v0.6.2](astral-sh/ruff-pre-commit@v0.5.5...v0.6.2)
- [github.com/psf/black: 24.4.2 → 24.8.0](psf/black@24.4.2...24.8.0)
- [github.com/pre-commit/mirrors-mypy: v1.11.0 → v1.11.2](pre-commit/mirrors-mypy@v1.11.0...v1.11.2)
- [github.com/abravalheri/validate-pyproject: v0.18 → v0.19](abravalheri/validate-pyproject@v0.18...v0.19)
- [github.com/pre-commit/mirrors-eslint: v9.8.0 → v9.9.1](pre-commit/mirrors-eslint@v9.8.0...v9.9.1)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Scott Barnes <scottreidbarnes@gmail.com>
  • Loading branch information
pre-commit-ci[bot] and scottbarnes authored Aug 31, 2024
1 parent 9dca010 commit 6e27575
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install --user ruff==0.0.286
- run: ruff --format=github .
- run: pip install --user ruff==0.6.2
- run: ruff check --output-format=github .
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ repos:
- id: auto-walrus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.6.2
hooks:
- id: ruff

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black # See pyproject.toml for args

Expand All @@ -55,7 +55,7 @@ repos:
- id: cython-lint

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
rev: v1.11.2
hooks:
- id: mypy # See pyproject.toml for args
additional_dependencies:
Expand All @@ -66,12 +66,12 @@ repos:
- types-simplejson

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
rev: v0.19
hooks:
- id: validate-pyproject

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.8.0
rev: v9.9.1
hooks:
- id: eslint
types: [file]
Expand Down
3 changes: 1 addition & 2 deletions openlibrary/catalog/add_book/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ def compare_author_keywords(e1_authors, e2_authors):
score = percent * 80
if ordered:
score += 10
if score > max_score:
max_score = score
max_score = max(score, max_score)
if max_score:
return ('authors', 'keyword match', max_score)
else:
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def add_languages(mock_site):
languages = [
('eng', 'English'),
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/catalog/add_book/tests/test_add_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def open_test_data(filename):
return open(fullpath, mode='rb')


@pytest.fixture()
@pytest.fixture
def ia_writeback(monkeypatch):
"""Prevent ia writeback from making live requests."""
monkeypatch.setattr(add_book, 'update_ia_metadata_for_ol_edition', lambda olid: {})
Expand Down Expand Up @@ -1481,7 +1481,7 @@ def test_overwrite_if_rev1_promise_item(name, edition, marc, expected) -> None:
), f"Test {name} failed. Expected {expected}, but got {result}"


@pytest.fixture()
@pytest.fixture
def setup_load_data(mock_site):
existing_author = {
'key': '/authors/OL1A',
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/catalog/add_book/tests/test_load_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from openlibrary.core.models import Author


@pytest.fixture()
@pytest.fixture
def new_import(monkeypatch):
monkeypatch.setattr(load_book, 'find_entity', lambda a: None)

Expand Down
6 changes: 3 additions & 3 deletions openlibrary/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_foo(monkeytime):
monkeypatch.setattr("time.sleep", mock_sleep)


@pytest.fixture()
@pytest.fixture
def monkeytime(monkeypatch):
cur_time = 1

Expand All @@ -59,12 +59,12 @@ def sleep(secs):
monkeypatch.setattr("time.sleep", sleep)


@pytest.fixture()
@pytest.fixture
def wildcard():
return Wildcard()


@pytest.fixture()
@pytest.fixture
def render_template(request):
"""Utility to test templates."""
template.load_templates("openlibrary")
Expand Down
3 changes: 1 addition & 2 deletions openlibrary/coverstore/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ def GET(self, category):
limit = safeint(i.limit, 10)
details = i.details.lower() == "true"

if limit > 100:
limit = 100
limit = min(limit, 100)

if i.olid and ',' in i.olid:
i.olid = i.olid.split(',')
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/coverstore/tests/test_coverstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]


@pytest.fixture()
@pytest.fixture
def image_dir(tmpdir):
tmpdir.mkdir('localdisk')
tmpdir.mkdir('items')
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/coverstore/tests/test_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setup_db():
db.insert('category', name='b')


@pytest.fixture()
@pytest.fixture
def image_dir(tmpdir):
tmpdir.mkdir('localdisk')
tmpdir.mkdir('items')
Expand Down
32 changes: 16 additions & 16 deletions openlibrary/i18n/test_po_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from babel.messages.pofile import read_po
import xml.etree.ElementTree as etree
import xml.etree.ElementTree as ET

from openlibrary.i18n import get_locales

Expand All @@ -11,25 +11,25 @@
ALLOW_FAILURES = {'pl'}


def trees_equal(el1: etree.Element, el2: etree.Element, error=True):
def trees_equal(el1: ET.Element, el2: ET.Element, error=True):
"""
Check if the tree data is the same
>>> trees_equal(etree.fromstring('<root />'), etree.fromstring('<root />'))
>>> trees_equal(ET.fromstring('<root />'), ET.fromstring('<root />'))
True
>>> trees_equal(etree.fromstring('<root x="3" />'),
... etree.fromstring('<root x="7" />'))
>>> trees_equal(ET.fromstring('<root x="3" />'),
... ET.fromstring('<root x="7" />'))
True
>>> trees_equal(etree.fromstring('<root x="3" y="12" />'),
... etree.fromstring('<root x="7" />'), error=False)
>>> trees_equal(ET.fromstring('<root x="3" y="12" />'),
... ET.fromstring('<root x="7" />'), error=False)
False
>>> trees_equal(etree.fromstring('<root><a /></root>'),
... etree.fromstring('<root />'), error=False)
>>> trees_equal(ET.fromstring('<root><a /></root>'),
... ET.fromstring('<root />'), error=False)
False
>>> trees_equal(etree.fromstring('<root><a /></root>'),
... etree.fromstring('<root><a>Foo</a></root>'), error=False)
>>> trees_equal(ET.fromstring('<root><a /></root>'),
... ET.fromstring('<root><a>Foo</a></root>'), error=False)
True
>>> trees_equal(etree.fromstring('<root><a href="" /></root>'),
... etree.fromstring('<root><a>Foo</a></root>'), error=False)
>>> trees_equal(ET.fromstring('<root><a href="" /></root>'),
... ET.fromstring('<root><a>Foo</a></root>'), error=False)
False
"""
try:
Expand Down Expand Up @@ -83,10 +83,10 @@ def gen_html_entries():

@pytest.mark.parametrize("locale,msgid,msgstr", gen_html_entries())
def test_html_format(locale: str, msgid: str, msgstr: str):
# Need this to support &nbsp;, since etree only parses XML.
# Need this to support &nbsp;, since ET only parses XML.
# Find a better solution?
entities = '<!DOCTYPE text [ <!ENTITY nbsp "&#160;"> ]>'
id_tree = etree.fromstring(f'{entities}<root>{msgid}</root>')
str_tree = etree.fromstring(f'{entities}<root>{msgstr}</root>')
id_tree = ET.fromstring(f'{entities}<root>{msgid}</root>')
str_tree = ET.fromstring(f'{entities}<root>{msgstr}</root>')
if not msgstr.startswith('<!-- i18n-lint no-tree-equal -->'):
assert trees_equal(id_tree, str_tree)
2 changes: 1 addition & 1 deletion openlibrary/mocks/mock_ia.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from openlibrary.core import ia


@pytest.fixture()
@pytest.fixture
def mock_ia(request, monkeypatch):
"""pytest funcarg to mock openlibrary.core.ia module.
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/mocks/mock_infobase.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def items(self, **kw):
return [(doc["_key"], doc) for doc in self._query(**kw)]


@pytest.fixture()
@pytest.fixture
def mock_site(request):
"""mock_site funcarg.
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/mocks/mock_memcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def delete(self, key):
self.cache.pop(key, None)


@pytest.fixture()
@pytest.fixture
def mock_memcache(request, monkeypatch):
"""This patches all the existing memcache connections to use mock memcache instance."""
m = monkeypatch
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/mocks/mock_ol.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from openlibrary.plugins import ol_infobase


@pytest.fixture()
@pytest.fixture
def ol(request):
"""ol funcarg for pytest tests.
Expand Down Expand Up @@ -50,7 +50,7 @@ def get_text(self, e=None, name=None, **kw):
class OL:
"""Mock OL object for all tests."""

@pytest.fixture()
@pytest.fixture
def __init__(self, request, monkeypatch):
self.request = request

Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/admin/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def serviceconfig(request):
import os
import yaml
Expand Down
6 changes: 3 additions & 3 deletions openlibrary/plugins/books/tests/test_dynlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from openlibrary.plugins.books import dynlinks


@pytest.fixture()
@pytest.fixture
def data0(request):
return {
"/books/OL0M": {"key": "/books/OL0M", "title": "book-0"},
Expand All @@ -34,7 +34,7 @@ def data0(request):
}


@pytest.fixture()
@pytest.fixture
def data1(request):
return {
"/books/OL1M": {
Expand All @@ -51,7 +51,7 @@ def data1(request):
}


@pytest.fixture()
@pytest.fixture
def data9(request):
return {
"/authors/OL9A": {"key": "/authors/OL9A", "name": "Mark Twain"},
Expand Down
6 changes: 2 additions & 4 deletions openlibrary/plugins/openlibrary/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ def GET(self, key):
return delegate.RawText(json.dumps(data), content_type="application/json")

def get_editions_data(self, work, limit, offset):
if limit > 1000:
limit = 1000
limit = min(limit, 1000)

keys = web.ctx.site.things(
{
Expand Down Expand Up @@ -403,8 +402,7 @@ def GET(self, key):
return delegate.RawText(json.dumps(data), content_type="application/json")

def get_works_data(self, author, limit, offset):
if limit > 1000:
limit = 1000
limit = min(limit, 1000)

keys = web.ctx.site.things(
{
Expand Down
2 changes: 1 addition & 1 deletion openlibrary/plugins/upstream/tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_process_goodreads_csv_with_bytes(self):
assert books_wo_isbns == self.expected_books_wo_isbns


@pytest.mark.xfail()
@pytest.mark.xfail
class TestAccount:
def signup(self, b, displayname, username, password, email):
b.open("/account/create")
Expand Down
4 changes: 2 additions & 2 deletions openlibrary/plugins/upstream/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import defaultdict
import re
import random
import xml.etree.ElementTree as etree
import xml.etree.ElementTree as ET
import datetime
import logging
from html.parser import HTMLParser
Expand Down Expand Up @@ -1449,7 +1449,7 @@ def _get_blog_feeds():
url = "https://blog.openlibrary.org/feed/"
try:
stats.begin("get_blog_feeds", url=url)
tree = etree.fromstring(requests.get(url).text)
tree = ET.fromstring(requests.get(url).text)
except Exception:
# Handle error gracefully.
logging.getLogger("openlibrary").error(
Expand Down
8 changes: 4 additions & 4 deletions openlibrary/tests/core/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest


@pytest.fixture()
@pytest.fixture
def dummy_crontabfile(request):
"Creates a dummy crontab file that can be used for to try things"
cronfile = os.tmpnam()
Expand All @@ -15,7 +15,7 @@ def dummy_crontabfile(request):
return cronfile


@pytest.fixture()
@pytest.fixture
def crontabfile(request):
"""Creates a file with an actual command that we can use to test
running of cron lines"""
Expand All @@ -30,7 +30,7 @@ def crontabfile(request):
return cronfile


@pytest.fixture()
@pytest.fixture
def counter(request):
"""Returns a decorator that will create a 'counted' version of the
functions. The number of times it's been called is kept in the
Expand All @@ -47,7 +47,7 @@ def _counted(*largs, **kargs):
return counter


@pytest.fixture()
@pytest.fixture
def sequence(request):
"""Returns a function that can be called for sequence numbers
similar to web.ctx.site.sequence.get_next"""
Expand Down
6 changes: 3 additions & 3 deletions openlibrary/tests/core/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ def setup_item_db():
db.query('delete from import_item;')


@pytest.fixture()
@pytest.fixture
def import_item_db(setup_item_db):
setup_item_db.multiple_insert('import_item', IMPORT_ITEM_DATA)
yield setup_item_db
setup_item_db.query('delete from import_item;')


@pytest.fixture()
@pytest.fixture
def import_item_db_staged(setup_item_db):
setup_item_db.multiple_insert('import_item', IMPORT_ITEM_DATA_STAGED)
yield setup_item_db
setup_item_db.query('delete from import_item;')


@pytest.fixture()
@pytest.fixture
def import_item_db_staged_and_pending(setup_item_db):
setup_item_db.multiple_insert('import_item', IMPORT_ITEM_DATA_STAGED_AND_PENDING)
yield setup_item_db
Expand Down
Loading

0 comments on commit 6e27575

Please sign in to comment.