docs: add ruff linting/formatting conventions for Python repos
This commit is contained in:
@@ -88,6 +88,54 @@ uv lock
|
|||||||
uv run pytest
|
uv run pytest
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Code Formatting & Linting (Ruff)
|
||||||
|
|
||||||
|
All Python code must pass `ruff check` and `ruff format` before merge. Ruff is configured in each repo's `pyproject.toml`:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 100
|
||||||
|
target-version = "py311"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["E", "F", "W", "I", "UP", "B", "C4", "SIM"]
|
||||||
|
ignore = ["E501"] # Line length handled by formatter
|
||||||
|
|
||||||
|
[tool.ruff.format]
|
||||||
|
quote-style = "double"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Required dev dependency:**
|
||||||
|
```toml
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = [
|
||||||
|
"pytest>=8.0.0",
|
||||||
|
"pytest-asyncio>=0.23.0",
|
||||||
|
"pytest-cov>=4.0.0", # For coverage in handler-base
|
||||||
|
"ruff>=0.1.0",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Local workflow:**
|
||||||
|
```bash
|
||||||
|
# Check and auto-fix
|
||||||
|
uv run ruff check --fix .
|
||||||
|
|
||||||
|
# Format code
|
||||||
|
uv run ruff format .
|
||||||
|
|
||||||
|
# Verify before commit
|
||||||
|
uv run ruff check . && uv run ruff format --check .
|
||||||
|
```
|
||||||
|
|
||||||
|
**CI enforcement:** All repos run ruff in the lint job. Commits that fail linting will not pass CI.
|
||||||
|
|
||||||
|
**Kubeflow pipeline variables:** For Kubeflow DSL pipelines, terminal task assignments that appear unused should have `# noqa: F841` comments, as these define the DAG structure:
|
||||||
|
```python
|
||||||
|
# Step 6: Final step (defines DAG dependency)
|
||||||
|
tts_task = synthesize_speech(text=llm_task.output) # noqa: F841
|
||||||
|
```
|
||||||
|
|
||||||
### Project Structure
|
### Project Structure
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|||||||
Reference in New Issue
Block a user