pythonのruffの概要と使い方
概要
- pythonのlinter
- 2023年で人気
- 高速
インストール
$ pipx install ruff
使い方
ruffの実行
$ ruff check <file>
ruffの実行(ディレクトリ)
$ ruff check <dir>
エラーの自動修正
$ ruff check <file> --fix
pre-commitに設定
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.9
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
GitHub actionsでの設定