Skip to content

Commit 267e284

Browse files
committed
Upgrade requirements and pre-commit (#345)
1 parent 4853683 commit 267e284

File tree

15 files changed

+123
-123
lines changed

15 files changed

+123
-123
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 24.3.0
3+
rev: 24.10.0
44
hooks:
55
- id: black
66

@@ -17,26 +17,26 @@ repos:
1717
files: \.html$
1818

1919
- repo: https://github.com/asottile/pyupgrade
20-
rev: v3.15.1
20+
rev: v3.19.0
2121
hooks:
2222
- id: pyupgrade
2323
args: [ "--py310-plus" ]
2424

2525
- repo: https://github.com/rtts/djhtml
26-
rev: '3.0.6'
26+
rev: '3.0.7'
2727
hooks:
2828
- id: djhtml
2929
- id: djcss
3030
- id: djjs
3131

3232
- repo: https://github.com/adamchainz/django-upgrade
33-
rev: 1.16.0
33+
rev: 1.22.2
3434
hooks:
3535
- id: django-upgrade
3636
args: [ --target-version, "4.1" ]
3737

3838
- repo: https://github.com/charliermarsh/ruff-pre-commit
39-
rev: 'v0.3.4'
39+
rev: 'v0.8.2'
4040
hooks:
4141
- id: ruff
4242
args: [--fix, --exit-non-zero-on-fix]

catalog/management/commands/load_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def slugify0(name):
3737

3838

3939
class Command(BaseCommand):
40-
def handle(self, *args: Any, **options: Any) -> None:
40+
def handle(self, *args: Any, **options: Any) -> None: # noqa: PLR0912
4141
with open("csv/programs.json") as f:
4242
programs = json.load(f)
4343

catalog/management/parser/build_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_or_create_bloc(fac: dict, program: dict, bloc: dict) -> dict:
2828
fac = get_or_create_fac(fac)
2929
program = get_or_create_program(fac, program)
3030

31-
bloc = bloc["val"] if bloc["val"] != "U" else "1"
31+
bloc = bloc["val"] if bloc["val"] != "U" else "1" # type: ignore
3232
if bloc not in program["blocs"]:
3333
program["blocs"][bloc] = {"val": bloc, "courses": {}}
3434
return program["blocs"][bloc]

catalog/tests/load_tree_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def test_fill_twice():
7373
assert course.name == new_course.name
7474

7575

76-
@pytest.mark.slow()
77-
@pytest.mark.network()
76+
@pytest.mark.slow
77+
@pytest.mark.network
7878
def test_load_tree_hit_ulb():
7979
call_command("loadtree", REAL_TREE, hitulb=True)
8080

documents/tasks.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,11 @@ def repair(self, document_id: int) -> int:
258258

259259
@contextlib.contextmanager
260260
def file_as_local(fileobj, prefix="", suffix=""):
261-
tmpfile = tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix)
262-
tmpfile.write(fileobj.read())
263-
tmpfile.flush()
261+
with tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix) as tmpfile:
262+
tmpfile.write(fileobj.read())
263+
tmpfile.flush()
264264

265-
try:
266265
yield tmpfile
267-
finally:
268-
tmpfile.close()
269266

270267

271268
@contextlib.contextmanager

documents/tests/celery_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def create_doc(name, ext):
4747
return doc
4848

4949

50-
@pytest.mark.slow()
50+
@pytest.mark.slow
5151
def test_add_to_queue():
5252
doc = create_doc("Document name", ".pdf")
5353
with open("documents/tests/files/3pages.pdf", "rb") as fd:
@@ -63,7 +63,7 @@ def test_add_to_queue():
6363
assert doc.original.path == doc.pdf.path
6464

6565

66-
@pytest.mark.slow()
66+
@pytest.mark.slow
6767
def test_send_duplicate():
6868
test_add_to_queue()
6969

@@ -80,8 +80,8 @@ def test_send_duplicate():
8080

8181

8282
# TODO : mock unoconv and provide a fake pdf instead
83-
@pytest.mark.unoconv()
84-
@pytest.mark.slow()
83+
@pytest.mark.unoconv
84+
@pytest.mark.slow
8585
def test_send_office():
8686
doc = create_doc("My office doc", ".docx")
8787

documents/tests/document_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
pytestmark = pytest.mark.django_db
1313

1414

15-
@pytest.fixture()
15+
@pytest.fixture
1616
def doc():
1717
user = User.objects.create_user(netid="test_user")
1818
doc = Document.objects.create(name="A document", user=user)

documents/tests/logic_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
pytestmark = pytest.mark.django_db
1313

1414

15-
@pytest.fixture()
15+
@pytest.fixture
1616
def user():
1717
return User.objects.create_user(netid="test_user")
1818

1919

20-
@pytest.fixture()
20+
@pytest.fixture
2121
def course():
2222
return Course.objects.create(slug="test-t-100")
2323

documents/thumbnail.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import statistics
44

5-
import fitz
5+
import pymupdf
66
from PIL import Image, ImageOps
77

88

9-
def _get_thumb_from_page(page: fitz.fitz.Page):
9+
def _get_thumb_from_page(page: pymupdf.Page):
1010
pix = page.get_pixmap()
1111
mode = "RGBA" if pix.alpha else "RGB"
1212
img = Image.frombytes(mode, (pix.width, pix.height), pix.samples)
@@ -18,7 +18,7 @@ def get_thumbnail(
1818
pdf: str | None = None, stream: IO[bytes] | None = None
1919
) -> tuple[int, Image.Image]:
2020
s = stream.read() if stream else None
21-
doc = fitz.open(filename=pdf, stream=s, filetype="pdf")
21+
doc = pymupdf.open(filename=pdf, stream=s, filetype="pdf")
2222

2323
# Iterate on the first 10 pages to find an interesting one to thumbnail
2424
for i in range(min(doc.page_count, 10)):

integration/test_webtest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@
1212
pytestmark = [pytest.mark.django_db, pytest.mark.webtest]
1313

1414

15-
@pytest.fixture()
15+
@pytest.fixture
1616
def app():
1717
wtm = django_webtest.WebTestMixin()
1818
wtm._patch_settings()
1919
yield django_webtest.DjangoTestApp()
2020
wtm._unpatch_settings()
2121

2222

23-
@pytest.fixture()
23+
@pytest.fixture
2424
def user():
2525
return User.objects.create_user(
2626
netid="nimarcha", email="lol@lol.be", first_name="Nikita", last_name="Marchant"
2727
)
2828

2929

30-
@pytest.fixture()
30+
@pytest.fixture
3131
def tags():
3232
return [Tag.objects.create(name="my tag"), Tag.objects.create(name="my other tag")]
3333

3434

35-
@pytest.fixture()
35+
@pytest.fixture
3636
def tree():
3737
root = Category.objects.create(name="ULB")
3838
science = Category.objects.create(name="science")

0 commit comments

Comments
 (0)