## [[Black]]の場合
https://black.readthedocs.io/en/stable/integrations/editors.html#pycharm-intellij-idea
[[BlackConnect]]を利用する。
`設定`
![[Pasted image 20220908153149.png]]
> [!error]- 設定を変更しようとするとaiohttpのエラーが出る
> エラーの内容。
>
> ```
> aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install to obtain aiohttp_cors: `pip install black[d]`
> ```
>
> `[d]`オプション付きのコマンド、`pip install black[d]`で[[Black]]を再インストールすればよい。
## [[Ruff]]の場合
[[Ruff(IntelliJ)]]を使う。`Use ruff format`にチェック。
![[Pasted image 20231029143833.png]]
[[Actions on Save]]で`Reformat code`に`Python`を割り当てる。
![[Pasted image 20231029144301.png]]
> [!question]- `Run ruff when the python file is saved` を有効にしないのはなぜ?
> 上記オプションを有効にすれば[[Actions on Save]]は不要に見える...が、実際は上記で実行される[[Ruff]]の処理にフォーマットが含まれない。(ver 0.0.24時点の場合)
> Issueは作成されているのでもし挙動が変われば、[[Actions on Save]]は不要になる可能性がある。
> > [Files are not formatted on save · Issue \#297 · koxudaxi/ruff\-pycharm\-plugin](https://github.com/koxudaxi/ruff-pycharm-plugin/issues/297)