[note] Python Ruff
官方文件
基本使用
# ruff format [directory]
$ uvx ruff format app # format app 資料夾
# ruff check --select I --fix [directory]
$ uvx ruff check --select I --fix app # fix app 資料夾
目前 ruff 的 format 不支援 sorting imports(reference)
Configuration
# pyproject.toml
[tool.ruff]
target-version = "py39"
fix = true
line-length = 120
exclude = [
"path_not_want_to_format",
]
[tool.ruff.lint]
select = [
"E", # pycodestyle
"F", # Pyflakes
"W", # pycodestyle
"I", # import
"B", # bugbear
]
[tool.ruff.format]
quote-style = "single"