README: add vscode and emacs ruff instructions
This commit is contained in:
26
README.md
26
README.md
@@ -170,22 +170,24 @@ pytest --doctest-modules --ignore-glob="*to_be_updated*" --ignore-glob=*pipeline
|
|||||||
|
|
||||||
## Setting up your editor
|
## 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
|
### 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
|
```elisp
|
||||||
(use-package py-autopep8
|
(use-package lazy-ruff
|
||||||
:ensure t
|
:ensure t
|
||||||
:defer t
|
:hook ((python-mode . lazy-ruff-mode))
|
||||||
:hook ((python-mode . py-autopep8-mode))
|
|
||||||
:config
|
: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
|
```elisp
|
||||||
(use-package pyvenv-auto
|
(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
|
### Visual Studio Code
|
||||||
|
|
||||||
Install the
|
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
|
```json
|
||||||
"[python]": {
|
"[python]": {
|
||||||
"editor.defaultFormatter": "ms-python.autopep8",
|
"editor.defaultFormatter": "charliermarsh.ruff",
|
||||||
"editor.formatOnSave": true
|
"editor.formatOnSave": true
|
||||||
},
|
},
|
||||||
"autopep8.args": [
|
"ruff.format.args": ["--config", "line-length=100"]
|
||||||
"-a",
|
|
||||||
"-a",
|
|
||||||
"--max-line-length=100"
|
|
||||||
],
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ grpcio-tools~=1.62.2
|
|||||||
pip-tools~=7.4.1
|
pip-tools~=7.4.1
|
||||||
pyright~=1.1.376
|
pyright~=1.1.376
|
||||||
pytest~=8.3.2
|
pytest~=8.3.2
|
||||||
ruff~=0.6.6
|
ruff~=0.6.7
|
||||||
setuptools~=72.2.0
|
setuptools~=72.2.0
|
||||||
setuptools_scm~=8.1.0
|
setuptools_scm~=8.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user