add style guide, ruff config, generation service extraction, remove Makefile

- Add backend/STYLE_GUIDE.md covering formatting, imports, types, docstrings,
  comments, error handling, async, logging, and naming conventions
- Add pyproject.toml with ruff linter/formatter config (ERA, FIX, isort, pyupgrade)
- Extract generation service (Phase 3): unified run_generation() replaces three
  duplicated closures, serial queue moved to services/task_queue.py
- Delete Makefile in favor of justfile; update all references
- Add Python lint/format/test commands to justfile (check-python, fix-python, test)
- Install ruff, pytest, pytest-asyncio as dev tools in setup-python
- Update REFACTOR_PLAN.md with Phase 3 and Phase 7 completion
This commit is contained in:
James Pine
2026-03-16 01:35:59 -07:00
parent 439fedcbf2
commit fe19a9ca47
13 changed files with 972 additions and 812 deletions
+81
View File
@@ -0,0 +1,81 @@
[project]
name = "voicebox-backend"
version = "0.2.3"
requires-python = ">=3.12"
# ---------------------------------------------------------------------------
# Ruff linter + formatter
# ---------------------------------------------------------------------------
[tool.ruff]
target-version = "py312"
line-length = 120
src = ["backend"]
# Files/dirs to skip entirely.
extend-exclude = [
"backend/voicebox-server.spec",
"backend/build_binary.py",
]
[tool.ruff.lint]
select = [
"F", # pyflakes
"E", # pycodestyle errors
"W", # pycodestyle warnings
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade (modernize syntax for 3.12)
"B", # flake8-bugbear
"A", # flake8-builtins (shadowing built-in names)
"SIM", # flake8-simplify
"T20", # flake8-print (flag print() calls)
"RET", # flake8-return
"PIE", # misc lints
"PT", # flake8-pytest-style
"RUF", # ruff-specific rules
"ERA", # commented-out code detection
"FIX", # flag TODO/FIXME/HACK/XXX for review
]
ignore = [
# Allow print() in existing code -- remove items from this list as files
# are migrated to logging during the refactor.
"T201", # print() found
# These conflict with the formatter or are too noisy during migration:
"E501", # line too long (formatter handles this)
"RET504", # unnecessary assignment before return
"SIM108", # use ternary operator (sometimes less readable)
"B008", # function call in default argument (FastAPI Depends() pattern)
"UP007", # use X | Y for union (auto-fixed by UP, but noisy on big diffs)
]
# Per-file rule overrides.
[tool.ruff.lint.per-file-ignores]
# Tests can use assert, print, and magic values freely.
"backend/tests/**" = ["S101", "T201", "PLR2004", "ERA001"]
# __init__.py re-exports are expected to have unused imports.
"**/__init__.py" = ["F401"]
# Entry points and scripts legitimately use print.
"backend/server.py" = ["T201"]
"backend/main.py" = ["T201"]
[tool.ruff.lint.isort]
known-first-party = ["backend"]
# Group "from backend.*" imports into the first-party section.
force-single-line = false
combine-as-imports = true
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
# ---------------------------------------------------------------------------
# pytest
# ---------------------------------------------------------------------------
[tool.pytest.ini_options]
testpaths = ["backend/tests"]
asyncio_mode = "auto"