ci: add ruff linting and mypy type checking
Add ruff and mypy to dev dependencies with configuration in pyproject.toml. Add a lint CI job that runs ruff check, ruff format --check, and mypy. Auto-fix import sorting and formatting across the codebase. Exclude alembic/versions from linting (auto-generated migrations). Ignore B008 (FastAPI Depends pattern) and RUF001 (unicode in user-facing strings). 21 ruff lint errors and 50 mypy errors remain for manual review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
399276ea69
commit
bf04c77aa9
137 changed files with 3066 additions and 1900 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
|
@ -25,7 +25,9 @@ def _job(
|
|||
)
|
||||
|
||||
|
||||
def _row(*, pub_url: str | None = "https://scholar.google.com/citations?view_op=view_citation&citation_for_view=abc:xyz") -> SimpleNamespace:
|
||||
def _row(
|
||||
*, pub_url: str | None = "https://scholar.google.com/citations?view_op=view_citation&citation_for_view=abc:xyz"
|
||||
) -> SimpleNamespace:
|
||||
return SimpleNamespace(
|
||||
publication_id=1,
|
||||
scholar_profile_id=1,
|
||||
|
|
@ -39,13 +41,13 @@ def _row(*, pub_url: str | None = "https://scholar.google.com/citations?view_op=
|
|||
pdf_url=None,
|
||||
is_read=False,
|
||||
is_favorite=False,
|
||||
first_seen_at=datetime(2026, 2, 22, 12, 0, tzinfo=timezone.utc),
|
||||
first_seen_at=datetime(2026, 2, 22, 12, 0, tzinfo=UTC),
|
||||
is_new_in_latest_run=True,
|
||||
)
|
||||
|
||||
|
||||
def test_pdf_queue_auto_enqueue_blocks_recent_attempt(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=timezone.utc)
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=UTC)
|
||||
monkeypatch.setattr(pdf_queue, "_utcnow", lambda: now)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_first_interval_seconds", lambda: 3_600)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_interval_seconds", lambda: 86_400)
|
||||
|
|
@ -59,7 +61,7 @@ def test_pdf_queue_auto_enqueue_blocks_recent_attempt(monkeypatch: pytest.Monkey
|
|||
|
||||
|
||||
def test_pdf_queue_auto_enqueue_blocks_recent_first_retry(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=timezone.utc)
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=UTC)
|
||||
monkeypatch.setattr(pdf_queue, "_utcnow", lambda: now)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_first_interval_seconds", lambda: 3_600)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_interval_seconds", lambda: 86_400)
|
||||
|
|
@ -73,7 +75,7 @@ def test_pdf_queue_auto_enqueue_blocks_recent_first_retry(monkeypatch: pytest.Mo
|
|||
|
||||
|
||||
def test_pdf_queue_auto_enqueue_blocks_after_max_attempts(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=timezone.utc)
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=UTC)
|
||||
monkeypatch.setattr(pdf_queue, "_utcnow", lambda: now)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_first_interval_seconds", lambda: 3_600)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_interval_seconds", lambda: 86_400)
|
||||
|
|
@ -87,7 +89,7 @@ def test_pdf_queue_auto_enqueue_blocks_after_max_attempts(monkeypatch: pytest.Mo
|
|||
|
||||
|
||||
def test_pdf_queue_auto_enqueue_blocks_second_retry_within_day(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=timezone.utc)
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=UTC)
|
||||
monkeypatch.setattr(pdf_queue, "_utcnow", lambda: now)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_first_interval_seconds", lambda: 3_600)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_interval_seconds", lambda: 86_400)
|
||||
|
|
@ -103,7 +105,7 @@ def test_pdf_queue_auto_enqueue_blocks_second_retry_within_day(monkeypatch: pyte
|
|||
def test_pdf_queue_manual_requeue_bypasses_cooldown_and_max_attempts(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=timezone.utc)
|
||||
now = datetime(2026, 2, 21, 12, 0, tzinfo=UTC)
|
||||
monkeypatch.setattr(pdf_queue, "_utcnow", lambda: now)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_first_interval_seconds", lambda: 3_600)
|
||||
monkeypatch.setattr(pdf_queue, "_auto_retry_interval_seconds", lambda: 86_400)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue