chore: fix all ruff lint warnings (unused imports, unsorted imports, unused vars)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
"""Tests for ICE extraction: format detection, XLS parsing, API client."""
|
"""Tests for ICE extraction: format detection, XLS parsing, API client."""
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import gzip
|
|
||||||
import io
|
import io
|
||||||
import struct
|
from unittest.mock import MagicMock
|
||||||
from unittest.mock import MagicMock, patch
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import xlwt # noqa: F401 — needed to create XLS fixtures; skip tests if missing
|
import xlwt # noqa: F401 — needed to create XLS fixtures; skip tests if missing
|
||||||
@@ -96,7 +94,7 @@ def test_fetch_report_listings_parses_response():
|
|||||||
_make_api_row("Certified Stock Aging Report", "/dl/aging.xls"),
|
_make_api_row("Certified Stock Aging Report", "/dl/aging.xls"),
|
||||||
])
|
])
|
||||||
|
|
||||||
from ice_stocks.ice_api import ICE_BASE_URL, fetch_report_listings
|
from ice_stocks.ice_api import ICE_BASE_URL
|
||||||
rows = fetch_report_listings(mock_session, product_id=2)
|
rows = fetch_report_listings(mock_session, product_id=2)
|
||||||
|
|
||||||
assert len(rows) == 2
|
assert len(rows) == 2
|
||||||
@@ -113,7 +111,6 @@ def test_fetch_report_listings_prepends_base_url_for_absolute():
|
|||||||
_make_api_row("Test", "https://other.example.com/file.xls"),
|
_make_api_row("Test", "https://other.example.com/file.xls"),
|
||||||
])
|
])
|
||||||
|
|
||||||
from ice_stocks.ice_api import fetch_report_listings
|
|
||||||
rows = fetch_report_listings(mock_session, product_id=2)
|
rows = fetch_report_listings(mock_session, product_id=2)
|
||||||
assert rows[0]["download_url"] == "https://other.example.com/file.xls"
|
assert rows[0]["download_url"] == "https://other.example.com/file.xls"
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ def fetch_country_data_from_duckdb() -> list[dict]:
|
|||||||
)
|
)
|
||||||
SELECT * FROM ranked LIMIT 30
|
SELECT * FROM ranked LIMIT 30
|
||||||
""").fetchall()
|
""").fetchall()
|
||||||
cols = [d[0] for d in conn.execute("""
|
_ = [d[0] for d in conn.execute("""
|
||||||
WITH latest AS (SELECT MAX(market_year) AS max_year FROM serving.commodity_metrics
|
WITH latest AS (SELECT MAX(market_year) AS max_year FROM serving.commodity_metrics
|
||||||
WHERE commodity_code = 711100 AND country_code IS NOT NULL)
|
WHERE commodity_code = 711100 AND country_code IS NOT NULL)
|
||||||
SELECT country_name, country_code, market_year, production * 1000,
|
SELECT country_name, country_code, market_year, production * 1000,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from quart import Blueprint, flash, g, redirect, render_template, request, url_for
|
from quart import Blueprint, flash, g, redirect, render_template, request, url_for
|
||||||
|
|
||||||
from ..core import execute, fetch_all, fetch_one, csrf_protect
|
from ..core import csrf_protect, execute, fetch_all, fetch_one
|
||||||
|
|
||||||
bp = Blueprint(
|
bp = Blueprint(
|
||||||
"cms",
|
"cms",
|
||||||
@@ -23,7 +23,8 @@ def admin_required(f):
|
|||||||
async def decorated(*args, **kwargs):
|
async def decorated(*args, **kwargs):
|
||||||
if "admin" not in (g.get("user") or {}).get("roles", []):
|
if "admin" not in (g.get("user") or {}).get("roles", []):
|
||||||
await flash("Admin access required.", "error")
|
await flash("Admin access required.", "error")
|
||||||
from quart import redirect as _redirect, url_for as _url_for
|
from quart import redirect as _redirect
|
||||||
|
from quart import url_for as _url_for
|
||||||
return _redirect(_url_for("auth.login"))
|
return _redirect(_url_for("auth.login"))
|
||||||
return await f(*args, **kwargs)
|
return await f(*args, **kwargs)
|
||||||
return decorated
|
return decorated
|
||||||
@@ -71,7 +72,7 @@ async def list_template_data(template_id: int) -> list[dict]:
|
|||||||
|
|
||||||
async def generate_article_from_data(data_row: dict, tmpl: dict) -> int | None:
|
async def generate_article_from_data(data_row: dict, tmpl: dict) -> int | None:
|
||||||
"""Generate (or regenerate) a single article from a template_data row."""
|
"""Generate (or regenerate) a single article from a template_data row."""
|
||||||
from jinja2 import Environment, BaseLoader
|
from jinja2 import BaseLoader, Environment
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(data_row["data_json"])
|
data = json.loads(data_row["data_json"])
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ from datetime import datetime
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from quart import Blueprint, render_template, request, redirect, url_for, flash, g, jsonify, session
|
from quart import Blueprint, flash, g, jsonify, redirect, render_template, request, session, url_for
|
||||||
|
|
||||||
from ..core import config, fetch_one, fetch_all, execute
|
|
||||||
from ..auth.routes import login_required
|
from ..auth.routes import login_required
|
||||||
|
from ..core import config, execute, fetch_one
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import json
|
|||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from .core import config, init_db, fetch_one, fetch_all, execute, send_email
|
from .core import config, execute, fetch_all, init_db, send_email
|
||||||
|
|
||||||
|
|
||||||
# Task handlers registry
|
# Task handlers registry
|
||||||
HANDLERS: dict[str, callable] = {}
|
HANDLERS: dict[str, callable] = {}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
Shared test fixtures for the BeanFlows test suite.
|
Shared test fixtures for the BeanFlows test suite.
|
||||||
"""
|
"""
|
||||||
import hashlib
|
|
||||||
import hmac
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
@@ -10,11 +8,9 @@ from unittest.mock import AsyncMock, patch
|
|||||||
import aiosqlite
|
import aiosqlite
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
from beanflows import core
|
from beanflows import core
|
||||||
from beanflows.app import create_app
|
from beanflows.app import create_app
|
||||||
|
|
||||||
|
|
||||||
SCHEMA_PATH = Path(__file__).parent.parent / "src" / "beanflows" / "migrations" / "schema.sql"
|
SCHEMA_PATH = Path(__file__).parent.parent / "src" / "beanflows" / "migrations" / "schema.sql"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import asyncio
|
|||||||
import duckdb
|
import duckdb
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
# ── Fixtures ────────────────────────────────────────────────────────────────
|
# ── Fixtures ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from hypothesis import settings as h_settings
|
|||||||
from hypothesis import strategies as st
|
from hypothesis import strategies as st
|
||||||
|
|
||||||
from beanflows.billing.routes import (
|
from beanflows.billing.routes import (
|
||||||
|
|
||||||
can_access_feature,
|
can_access_feature,
|
||||||
get_billing_customer,
|
get_billing_customer,
|
||||||
get_subscription,
|
get_subscription,
|
||||||
@@ -66,7 +65,7 @@ class TestUpsertSubscription:
|
|||||||
status="active",
|
status="active",
|
||||||
provider_subscription_id="sub_same",
|
provider_subscription_id="sub_same",
|
||||||
)
|
)
|
||||||
returned_id = await upsert_subscription(
|
await upsert_subscription(
|
||||||
user_id=test_user["id"],
|
user_id=test_user["id"],
|
||||||
plan="pro",
|
plan="pro",
|
||||||
status="active",
|
status="active",
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from unittest.mock import MagicMock
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
CHECKOUT_METHOD = "POST"
|
CHECKOUT_METHOD = "POST"
|
||||||
CHECKOUT_PLAN = "starter"
|
CHECKOUT_PLAN = "starter"
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import json
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from conftest import make_webhook_payload, sign_payload
|
from conftest import make_webhook_payload, sign_payload
|
||||||
|
|
||||||
from hypothesis import HealthCheck, given
|
from hypothesis import HealthCheck, given
|
||||||
from hypothesis import settings as h_settings
|
from hypothesis import settings as h_settings
|
||||||
from hypothesis import strategies as st
|
from hypothesis import strategies as st
|
||||||
|
|
||||||
from beanflows.billing.routes import get_billing_customer, get_subscription
|
from beanflows.billing.routes import get_billing_customer, get_subscription
|
||||||
|
|
||||||
|
|
||||||
WEBHOOK_PATH = "/billing/webhook/paddle"
|
WEBHOOK_PATH = "/billing/webhook/paddle"
|
||||||
SIG_HEADER = "Paddle-Signature"
|
SIG_HEADER = "Paddle-Signature"
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ and admin route protection.
|
|||||||
import pytest
|
import pytest
|
||||||
from quart import Blueprint
|
from quart import Blueprint
|
||||||
|
|
||||||
|
from beanflows import core
|
||||||
from beanflows.auth.routes import (
|
from beanflows.auth.routes import (
|
||||||
ensure_admin_role,
|
ensure_admin_role,
|
||||||
grant_role,
|
grant_role,
|
||||||
revoke_role,
|
revoke_role,
|
||||||
role_required,
|
role_required,
|
||||||
)
|
)
|
||||||
from beanflows import core
|
|
||||||
|
|
||||||
|
|
||||||
# ════════════════════════════════════════════════════════════
|
# ════════════════════════════════════════════════════════════
|
||||||
# grant_role / revoke_role
|
# grant_role / revoke_role
|
||||||
|
|||||||
Reference in New Issue
Block a user