diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 132028a..6639943 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -45,7 +45,7 @@ test:web: script: - uv sync --all-packages - cd web && uv run pytest tests/ -x -q - - cd web && uv run ruff check src/ tests/ + - uv run ruff check . # ── Tag (pull-based deploy) ─────────────────────────────────────────────────── # Creates v tag after all tests pass. The on-server supervisor polls for new diff --git a/extract/coffee_prices/src/coffee_prices/execute.py b/extract/coffee_prices/src/coffee_prices/execute.py index 694e7ba..cf28ef9 100644 --- a/extract/coffee_prices/src/coffee_prices/execute.py +++ b/extract/coffee_prices/src/coffee_prices/execute.py @@ -15,8 +15,14 @@ import sys from pathlib import Path import yfinance as yf -from extract_core import content_hash, end_run, landing_path, open_state_db, start_run -from extract_core import write_bytes_atomic +from extract_core import ( + content_hash, + end_run, + landing_path, + open_state_db, + start_run, + write_bytes_atomic, +) logging.basicConfig( level=logging.INFO, diff --git a/extract/psdonline/src/psdonline/execute.py b/extract/psdonline/src/psdonline/execute.py index b4f7300..9574d56 100644 --- a/extract/psdonline/src/psdonline/execute.py +++ b/extract/psdonline/src/psdonline/execute.py @@ -1,4 +1,3 @@ -from .normalize import normalize_zipped_csv import logging import os import sys @@ -7,8 +6,16 @@ from io import BytesIO from pathlib import Path import niquests -from extract_core import end_run, landing_path, normalize_etag, open_state_db, start_run -from extract_core import write_bytes_atomic +from extract_core import ( + end_run, + landing_path, + normalize_etag, + open_state_db, + start_run, + write_bytes_atomic, +) + +from .normalize import normalize_zipped_csv logging.basicConfig( level=logging.INFO, diff --git a/extract/psdonline/src/psdonline/normalize.py b/extract/psdonline/src/psdonline/normalize.py index 769caf3..b555c36 100644 --- a/extract/psdonline/src/psdonline/normalize.py +++ b/extract/psdonline/src/psdonline/normalize.py @@ -1,8 +1,7 @@ -import zipfile import gzip -from io import BytesIO import pathlib - +import zipfile +from io import BytesIO def normalize_zipped_csv(buffer: BytesIO)->BytesIO: diff --git a/pyproject.toml b/pyproject.toml index 0951e4b..9364ad6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,14 +88,15 @@ exclude = [ "site-packages", "venv", "notebooks", - "web", ] +line-length = 100 indent-width = 4 target-version = "py313" [tool.ruff.lint] +select = ["E", "F", "I", "UP"] ignore = [ "E501", # line too long (handled by formatter) diff --git a/scripts/hooks/pre-commit b/scripts/hooks/pre-commit index 2e4caa3..5ad6543 100644 --- a/scripts/hooks/pre-commit +++ b/scripts/hooks/pre-commit @@ -11,12 +11,8 @@ if [[ ! -x "$RUFF" ]]; then exit 1 fi -echo "→ ruff check (root)" +echo "→ ruff check" "$RUFF" check --fix "$REPO_ROOT" -echo "→ ruff check (web/src web/tests)" -"$RUFF" check --fix "$REPO_ROOT/web/src" "$REPO_ROOT/web/tests" \ - --config "$REPO_ROOT/web/pyproject.toml" - # Re-stage any files ruff fixed so they land in the commit. git diff --name-only | xargs -r git add diff --git a/tests/test_cot_extraction.py b/tests/test_cot_extraction.py index 17f94c6..2f3a9ca 100644 --- a/tests/test_cot_extraction.py +++ b/tests/test_cot_extraction.py @@ -7,7 +7,6 @@ from unittest.mock import MagicMock from cftc_cot.normalize import find_csv_inner_filename, normalize_zipped_csv - # ============================================================================= # normalize.py # ============================================================================= diff --git a/tests/test_ice_extraction.py b/tests/test_ice_extraction.py index 7fbc35c..9983a55 100644 --- a/tests/test_ice_extraction.py +++ b/tests/test_ice_extraction.py @@ -6,7 +6,6 @@ from unittest.mock import MagicMock import pytest import xlwt # noqa: F401 — needed to create XLS fixtures; skip tests if missing - from ice_stocks.ice_api import fetch_report_listings, find_latest_report from ice_stocks.xls_parse import OLE2_MAGIC, detect_file_format, xls_to_rows diff --git a/web/pyproject.toml b/web/pyproject.toml index 3f7a002..2dc0772 100644 --- a/web/pyproject.toml +++ b/web/pyproject.toml @@ -36,14 +36,6 @@ dev-dependencies = [ "ruff>=0.3.0", ] -[tool.ruff] -line-length = 100 -target-version = "py311" - -[tool.ruff.lint] -select = ["E", "F", "I", "UP"] -ignore = ["E501"] - [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"] diff --git a/web/src/beanflows/admin/cms_routes.py b/web/src/beanflows/admin/cms_routes.py index 9ab6788..d217b64 100644 --- a/web/src/beanflows/admin/cms_routes.py +++ b/web/src/beanflows/admin/cms_routes.py @@ -23,8 +23,7 @@ def admin_required(f): async def decorated(*args, **kwargs): if "admin" not in (g.get("user") or {}).get("roles", []): await flash("Admin access required.", "error") - from quart import redirect as _redirect - from quart import url_for as _url_for + from quart import redirect as _redirect, url_for as _url_for return _redirect(_url_for("auth.login")) return await f(*args, **kwargs) return decorated diff --git a/web/src/beanflows/app.py b/web/src/beanflows/app.py index 6dab9ee..fdc74d2 100644 --- a/web/src/beanflows/app.py +++ b/web/src/beanflows/app.py @@ -105,8 +105,7 @@ def create_app() -> Quart: # Health check @app.route("/health") async def health(): - from .analytics import _db_path as serving_db_path - from .analytics import fetch_analytics + from .analytics import _db_path as serving_db_path, fetch_analytics from .core import fetch_one result = {"status": "healthy", "sqlite": "ok", "duckdb": "ok"} try: diff --git a/web/src/beanflows/scripts/setup_paddle.py b/web/src/beanflows/scripts/setup_paddle.py index 9463d07..e3fed6d 100644 --- a/web/src/beanflows/scripts/setup_paddle.py +++ b/web/src/beanflows/scripts/setup_paddle.py @@ -13,8 +13,7 @@ import os import sys from dotenv import load_dotenv -from paddle_billing import Client as PaddleClient -from paddle_billing import Environment, Options +from paddle_billing import Client as PaddleClient, Environment, Options from paddle_billing.Entities.Shared import CurrencyCode, Money, TaxCategory from paddle_billing.Resources.Prices.Operations import CreatePrice from paddle_billing.Resources.Products.Operations import CreateProduct diff --git a/web/tests/test_billing_helpers.py b/web/tests/test_billing_helpers.py index 5f89501..8c16837 100644 --- a/web/tests/test_billing_helpers.py +++ b/web/tests/test_billing_helpers.py @@ -14,9 +14,7 @@ from beanflows.billing.routes import ( upsert_subscription, ) from beanflows.core import config -from hypothesis import HealthCheck, given -from hypothesis import settings as h_settings -from hypothesis import strategies as st +from hypothesis import HealthCheck, given, settings as h_settings, strategies as st # ════════════════════════════════════════════════════════════ # get_subscription diff --git a/web/tests/test_billing_webhooks.py b/web/tests/test_billing_webhooks.py index bfef5ce..3e2b061 100644 --- a/web/tests/test_billing_webhooks.py +++ b/web/tests/test_billing_webhooks.py @@ -7,9 +7,7 @@ import json import pytest from beanflows.billing.routes import get_billing_customer, get_subscription from conftest import make_webhook_payload, sign_payload -from hypothesis import HealthCheck, given -from hypothesis import settings as h_settings -from hypothesis import strategies as st +from hypothesis import HealthCheck, given, settings as h_settings, strategies as st WEBHOOK_PATH = "/billing/webhook/paddle" SIG_HEADER = "Paddle-Signature"