From a4420dc88b105d14a105a9349d0c2c4576478823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 23 Sep 2024 09:29:02 -0700 Subject: [PATCH] README: add vscode and emacs ruff instructions --- README.md | 26 ++++++++++++-------------- dev-requirements.txt | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 5dfc1ad95..faf0137dc 100644 --- a/README.md +++ b/README.md @@ -170,22 +170,24 @@ pytest --doctest-modules --ignore-glob="*to_be_updated*" --ignore-glob=*pipeline ## Setting up your editor -This project uses strict [PEP 8](https://peps.python.org/pep-0008/) formatting. +This project uses strict [PEP 8](https://peps.python.org/pep-0008/) formatting via [Ruff](https://github.com/astral-sh/ruff). ### Emacs -You can use [use-package](https://github.com/jwiegley/use-package) to install [py-autopep8](https://codeberg.org/ideasman42/emacs-py-autopep8) package and configure `autopep8` arguments: +You can use [use-package](https://github.com/jwiegley/use-package) to install [emacs-lazy-ruff](https://github.com/christophermadsen/emacs-lazy-ruff) package and configure `ruff` arguments: ```elisp -(use-package py-autopep8 +(use-package lazy-ruff :ensure t - :defer t - :hook ((python-mode . py-autopep8-mode)) + :hook ((python-mode . lazy-ruff-mode)) :config - (setq py-autopep8-options '("-a" "-a", "--max-line-length=100"))) + (setq lazy-ruff-format-command "ruff format --config line-length=100") + (setq lazy-ruff-only-format-block t) + (setq lazy-ruff-only-format-region t) + (setq lazy-ruff-only-format-buffer t)) ``` -`autopep8` was installed in the `venv` environment described before, so you should be able to use [pyvenv-auto](https://github.com/ryotaro612/pyvenv-auto) to automatically load that environment inside Emacs. +`ruff` was installed in the `venv` environment described before, so you should be able to use [pyvenv-auto](https://github.com/ryotaro612/pyvenv-auto) to automatically load that environment inside Emacs. ```elisp (use-package pyvenv-auto @@ -198,18 +200,14 @@ You can use [use-package](https://github.com/jwiegley/use-package) to install [p ### Visual Studio Code Install the -[autopep8](https://marketplace.visualstudio.com/items?itemName=ms-python.autopep8) extension. Then edit the user settings (_Ctrl-Shift-P_ `Open User Settings (JSON)`) and set it as the default Python formatter, enable formatting on save and configure `autopep8` arguments: +[Ruff](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff) extension. Then edit the user settings (_Ctrl-Shift-P_ `Open User Settings (JSON)`) and set it as the default Python formatter, enable formatting on save and configure `ruff` arguments: ```json "[python]": { - "editor.defaultFormatter": "ms-python.autopep8", + "editor.defaultFormatter": "charliermarsh.ruff", "editor.formatOnSave": true }, -"autopep8.args": [ - "-a", - "-a", - "--max-line-length=100" -], +"ruff.format.args": ["--config", "line-length=100"] ``` ## Getting help diff --git a/dev-requirements.txt b/dev-requirements.txt index cce356b14..c706d8fe6 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,6 +3,6 @@ grpcio-tools~=1.62.2 pip-tools~=7.4.1 pyright~=1.1.376 pytest~=8.3.2 -ruff~=0.6.6 +ruff~=0.6.7 setuptools~=72.2.0 setuptools_scm~=8.1.0