Migration 1: remove idx_sessions_token_hash from _SCHEMA_STATEMENTS. The legacy schema has sessions.token (not token_hash). The IF NOT EXISTS guard only prevents duplicate index names — it still requires the column to exist. Migration 2 drops and rebuilds sessions with token_hash anyway, so creating the index in migration 1 was redundant. Migration 3: replace ALTER TABLE ADD COLUMN with a table rebuild. SQLite rejects ALTER TABLE ADD COLUMN NOT NULL DEFAULT <expression> when the table already contains rows. The old DB has ~181k geo_cache rows, so the ALTER always failed. Rebuild copies existing rows with last_seen set to cached_at as a reasonable approximation of last-seen time.
77 lines
2.0 KiB
TOML
77 lines
2.0 KiB
TOML
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[project]
|
|
name = "bangui-backend"
|
|
version = "0.9.19-rc.3"
|
|
description = "BanGUI backend — fail2ban web management interface"
|
|
requires-python = ">=3.12"
|
|
dependencies = [
|
|
"fastapi>=0.115.0",
|
|
"uvicorn[standard]>=0.32.0",
|
|
"pydantic>=2.9.0",
|
|
"pydantic-settings>=2.6.0",
|
|
"aiosqlite>=0.20.0",
|
|
"aiohttp>=3.11.0",
|
|
"apscheduler>=3.10,<4.0",
|
|
"bcrypt>=4.2.0",
|
|
"geoip2>=4.8.0",
|
|
"prometheus-client>=0.21.0",
|
|
"regexploit>=1.0.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=8.3.0",
|
|
"pytest-asyncio>=0.24.0",
|
|
"httpx>=0.27.0",
|
|
"ruff>=0.8.0",
|
|
"mypy>=1.13.0",
|
|
"pytest-cov>=6.0.0",
|
|
"pytest-mock>=3.14.0",
|
|
"import-linter>=2.0.0",
|
|
]
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["app"]
|
|
|
|
[tool.ruff]
|
|
line-length = 120
|
|
target-version = "py312"
|
|
|
|
[tool.ruff.lint]
|
|
select = ["E", "F", "W", "I", "N", "UP", "B", "C4", "SIM", "TCH"]
|
|
ignore = ["B008"] # FastAPI uses function calls in default arguments (Depends)
|
|
|
|
[tool.ruff.lint.per-file-ignores]
|
|
# sys.path manipulation before stdlib imports is intentional in test helpers
|
|
# pytest evaluates fixture type annotations at runtime, so TC001/TC002/TC003 are false-positives
|
|
"tests/**" = ["E402", "TC001", "TC002", "TC003"]
|
|
"app/routers/**" = ["TC001", "TC002"] # FastAPI evaluates Depends() type aliases at runtime via get_type_hints()
|
|
|
|
[tool.ruff.format]
|
|
quote-style = "double"
|
|
|
|
[tool.mypy]
|
|
python_version = "3.12"
|
|
strict = true
|
|
plugins = ["pydantic.mypy"]
|
|
|
|
[tool.pytest.ini_options]
|
|
asyncio_mode = "auto"
|
|
pythonpath = [".", "../fail2ban-master"]
|
|
testpaths = ["tests"]
|
|
addopts = "--asyncio-mode=auto --cov=app --cov-report=term-missing"
|
|
filterwarnings = ["ignore::pytest.PytestRemovedIn9Warning"]
|
|
|
|
[tool.importlinter]
|
|
package_root = "app"
|
|
root_packages = ["app"]
|
|
|
|
[[tool.importlinter.contracts]]
|
|
name = "forbid_router_db_import"
|
|
type = "forbidden"
|
|
source_modules = ["app.routers"]
|
|
forbidden_modules = ["app.dependencies"]
|