fix: align Ruff checks and isolate configuration tests

This commit is contained in:
hungtran24 2026-10-02 12:31:42 +07:00
parent 2193d7c8e1
commit 655202455b
4 changed files with 17 additions and 4 deletions

View File

@ -1,10 +1,16 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.11
- repo: local
hooks:
- id: ruff
name: ruff (uv.lock)
entry: uv run --no-sync ruff check
language: system
types_or: [python, pyi]
- id: ruff-format
args: [--check]
name: ruff format (uv.lock)
entry: uv run --no-sync ruff format --check
language: system
types_or: [python, pyi]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0

View File

@ -45,5 +45,8 @@ line-length = 100
target-version = "py313"
src = ["src", "tests"]
[tool.ruff.lint]
select = ["E4", "E7", "E9", "F"]
[tool.ruff.lint.per-file-ignores]
"src/ai_platform/presentation/http/*.py" = ["B008"]

View File

@ -71,7 +71,10 @@ def test_operator_lifecycle_and_admin_session_revoke():
assert initial_key not in listed.text and "verifier" not in listed.text
assert client.delete(path).status_code == 403
run_path = f"/v1/lead-scoring/runs/{uuid4()}"
auth = lambda key: {"Authorization": f"Bearer {key}"}
def auth(key: str) -> dict[str, str]:
return {"Authorization": f"Bearer {key}"}
assert client.get(run_path, headers=auth(initial_key)).status_code == 404
rotated_key = asyncio.run(rotate())
assert rotated_key != initial_key

View File

@ -146,6 +146,7 @@ def test_seed_rejects_readback_without_persisted_snapshot():
seed_demo.seed_demo(client, settings(), "existing-app-secret")
@pytest.mark.usefixtures("isolated_settings")
def test_seed_refuses_non_development_or_nonlocal_database_names():
with pytest.raises(SystemExit, match="must be development"):
seed_demo.validate_local_target(Settings(environment="production"))