From 34cf1258735b805279bf1bfbb237348a68cf3d43 Mon Sep 17 00:00:00 2001 From: "Eshwen Bhal, PhD" Date: Tue, 30 Jan 2024 12:01:14 +0000 Subject: [PATCH] Update docs to replace Black with ruff formatter --- docs/tooling/quality.md | 41 ++++++++++------------------------------ pycharm/watchers.xml | 42 ----------------------------------------- 2 files changed, 10 insertions(+), 73 deletions(-) delete mode 100644 pycharm/watchers.xml diff --git a/docs/tooling/quality.md b/docs/tooling/quality.md index 2191db5..56fb949 100644 --- a/docs/tooling/quality.md +++ b/docs/tooling/quality.md @@ -22,45 +22,27 @@ To automatically fix any issues, run ruff --fix my_project/ tests/ ``` -### PyCharm integration - -You can also install the [Ruff plugin for PyCharm] to run it automatically on file changes. In **Preferences** | -**Tools** | **Ruff**, configure it as you like. - -To aid in documentation, in PyCharm go to **Preferences** | **Tools** | **Python Integrated Tools**. Under -**Docstrings**, select the docstring format as Google. - -## Black - -[Black] is a widely-used tool to ensure consistently-formatted code. +Ruff now contains a formatter to replace [Black]. It ensures consistently-formatted, highly readable code. -To automatically reformat your code, run +To automatically format your code, run ```shell -black my_project/ tests/ +ruff format my_project/ tests/ ``` -To instead just show what `black` would change, run +To instead just show what `ruff` would change, run ```shell -black --diff my_project/ tests/ +ruff format --diff my_project/ tests/ ``` ### PyCharm integration -`black` is integrated into PyCharm as of v2023.2. Go to **Settings** | **Tools** | **Black** to configure. - -??? tip "For older versions" - - PyCharm supports file watchers, which automatically run a command when a file is saved. This is useful for - transparently formatting code. - - To include `black` as a file watcher, go to **Settings** | **Tools** | **File Watchers** and import the - [watchers.xml]. This will automatically apply formatting to Python files and Jupyter notebooks. You may need to - edit the **Program** path to point to your `black` executable. +You can also install the [Ruff plugin for PyCharm] to run it automatically on file changes. In **Preferences** | +**Tools** | **Ruff**, configure it as you like. -Otherwise, to set it up yourself, follow the instructions -at . +To aid in documentation, in PyCharm go to **Preferences** | **Tools** | **Python Integrated Tools**. Under +**Docstrings**, select the docstring format as Google. ## Mypy @@ -112,8 +94,7 @@ The [.pre-commit-config.yaml] file contains hooks to run - built-in `pre-commit` checks - Automatic use of the walrus operator -- `ruff` for linting (fixes fixable issues) -- `black` for formatting (fixes fixable issues) +- `ruff` for linting and formatting (fixes fixable issues) - `mypy` type-hinting errors - `poetry` dependency status (`poetry.lock` and requirements files are up-to-date) @@ -132,8 +113,6 @@ pre-commit run -a [pyproject.toml]: https://github.com/eshwen/ds-python-boilerplate/blob/main/pyproject.toml -[watchers.xml]: https://github.com/eshwen/ds-python-boilerplate/blob/main/pycharm/watchers.xml - [pre-commit]: https://pre-commit.com/ [Ruff]: https://beta.ruff.rs/docs/ diff --git a/pycharm/watchers.xml b/pycharm/watchers.xml deleted file mode 100644 index 21f0793..0000000 --- a/pycharm/watchers.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - -