## 事象 以下のコードはimportのソート順が望ましくないため、[[Ruff]]の[[リンター]]がwarningを出してほしいのにwarningが出ない。 ![[Pasted image 20240416163519.png]] また、[[Lspsaga]]経由でCode Actionsの`Organize Import`を実行しても何も起こらない。実行したらソート順が最適化されてほしい。 ## 原因 デフォルトでは[[isort]]のような機能は有効になっていないため。 ## 解決方法 コマンドラインで `ruff check --fix --select I` のように `--select I` を指定する。もしくは、[[pyproject.toml]]に以下の設定を追加する。 ```toml [tool.ruff.lint] extend-select = ["I"] ``` ## 参考 - [`ruff format` doesn't sort imports, leaves file unchanged · Issue #8926 · astral-sh/ruff](https://github.com/astral-sh/ruff/issues/8926)