Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ packages = ["src/secfoo"]

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.ruff.lint.flake8-bugbear]
# typer.Option and FastAPI's Form are designed to be used as parameter
# defaults (they describe the parameter, they aren't shared mutable state),
# so B008 reports them as false positives.
extend-immutable-calls = ["typer.Option", "fastapi.Form"]
32 changes: 32 additions & 0 deletions tests/test_lint_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""ruff config: typer.Option / FastAPI Form defaults are not B008 findings."""
from __future__ import annotations

import importlib.util
import shutil
import subprocess
import sys
from pathlib import Path

import pytest

REPO_ROOT = Path(__file__).resolve().parent.parent


def _ruff() -> list[str]:
exe = shutil.which("ruff")
if exe:
return [exe]
if importlib.util.find_spec("ruff") is None:
pytest.skip("ruff is not installed (pip install -e '.[dev]')")
return [sys.executable, "-m", "ruff"]


def test_typer_and_fastapi_defaults_are_not_flagged_by_b008():
result = subprocess.run(
[*_ruff(), "check", "src", "--select", "B008", "--output-format", "concise"],
check=False,
cwd=REPO_ROOT,
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stdout + result.stderr
Loading