一键导入
ruff
Ruff — fast Python linter and formatter replacing flake8, black, isort. Configuration, rule selection, and common fixes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Ruff — fast Python linter and formatter replacing flake8, black, isort. Configuration, rule selection, and common fixes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | ruff |
| description | Ruff — fast Python linter and formatter replacing flake8, black, isort. Configuration, rule selection, and common fixes. |
uv run ruff check . # lint
uv run ruff check --fix . # lint + auto-fix safe fixes
uv run ruff check --fix --unsafe-fixes . # include unsafe fixes
uv run ruff format . # format (like black)
uv run ruff format --check . # format check only (CI)
uv run ruff check --select ALL . # see all possible violations
[tool.ruff]
target-version = "py310"
line-length = 100
src = ["src", "tests"]
[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes (undefined names, unused imports)
"I", # isort (import ordering)
"UP", # pyupgrade (modernize syntax)
"B", # flake8-bugbear (common bugs)
"SIM", # flake8-simplify
"N", # pep8-naming
"RUF", # ruff-specific rules
]
ignore = [
"E501", # line too long (formatter handles this)
"N802", # lowercase function names (math notation)
"N803", # lowercase argument names
"N806", # lowercase variable in function
"B905", # zip without strict=True
"SIM108", # ternary over if-else
]
# Per-file ignores
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"] # allow assert in tests
"scripts/*" = ["T201"] # allow print in scripts
[tool.ruff.lint.isort]
known-first-party = ["stgraph_fs"]
| Code | Rule | Description |
|---|---|---|
F401 | unused-import | Imported but unused |
F841 | unused-variable | Assigned but never used |
E711 | comparison-to-none | Use is None not == None |
UP006 | deprecated-collection-type | List[x] → list[x] |
UP007 | deprecated-union | Optional[x] → x | None |
B006 | mutable-default-arg | Mutable default in function def |
B007 | unused-loop-var | Loop variable unused (use _) |
I001 | unsorted-imports | Imports not sorted per isort |
RUF010 | explicit-f-string | str(x) inside f-string → {x!s} |
import os # noqa: F401 — suppress specific rule
x = 1 # noqa — suppress all rules on line (avoid)
Ruff auto-fixes many UP rules:
# Before (ruff --fix)
from typing import List, Optional, Dict
def f(x: Optional[int]) -> List[Dict[str, int]]:
...
# After
def f(x: int | None) -> list[dict[str, int]]:
...
ruff format and ruff check --fix are separate commands — run both.select = ["ALL"] enables experimental rules; always pin ignore list before using in CI.line-length in [tool.ruff] applies to the formatter; set it in [tool.ruff.lint] too if using E501.ruff check --select I --fix to reconcile.PM2 — process manager for long-running training jobs on remote servers. ecosystem.config.js, common commands, and SSH workflow with uv.
pre-commit — git hook framework for automating ruff, pyright, pytest, and other checks before every commit
Pyright static type checker — configuration, common errors, type annotation patterns for Python 3.10+ with uv projects
pytest — test structure, fixtures, markers, parametrize, conftest, and pytest-watch for automated testing in uv projects
uv — Python package manager, dependency management, virtual environments, and script running. Replaces pip, pip-tools, virtualenv, pyenv.