From 16b3571691b5de637f28235a041493c7e3a1b5c9 Mon Sep 17 00:00:00 2001 From: Man Ting Chan Date: Fri, 9 Feb 2024 14:39:10 +0000 Subject: [PATCH] replaced all docs refs of 'black' to 'ruff' --- docs/conf.py | 2 +- docs/explanations/decisions/0008-use-tox.md | 16 ++++++++-------- docs/reference/standards.rst | 2 +- .../{% if sphinx %}docs{% endif %}/conf.py.jinja | 2 +- .../developer/how-to/lint.rst | 11 +++-------- .../developer/reference/standards.rst | 1 - 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 11970474..312bb6d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -84,7 +84,7 @@ # Common links that should be available on every page rst_epilog = """ .. _Diamond Light Source: http://www.diamond.ac.uk -.. _black: https://github.com/psf/black +.. _ruff: https://github.com/astral-sh/ruff .. _flake8: https://flake8.pycqa.org/en/latest/ .. _isort: https://github.com/PyCQA/isort .. _pyright: https://microsoft.github.io/pyright/#/ diff --git a/docs/explanations/decisions/0008-use-tox.md b/docs/explanations/decisions/0008-use-tox.md index dfef5130..0289a2a5 100644 --- a/docs/explanations/decisions/0008-use-tox.md +++ b/docs/explanations/decisions/0008-use-tox.md @@ -26,7 +26,7 @@ against the changes you are about to commit. There are a number of things that CI needs to run: - pytest -- black +- ruff - pyright - flake8 - isort @@ -44,7 +44,7 @@ under pytest that had a plugin, and isort under flake8: subgraph cluster_0 { label = "pytest" - "pytest-black" + "pytest-ruff" "pytest-pyright" subgraph cluster_1 { label = "pytest-flake8" @@ -68,7 +68,7 @@ To address this, the tree was rearranged: node [fontname="Lato" fontsize=10 shape=box style=filled fillcolor="#8BC4E9"] pytest - black + ruff pyright subgraph cluster_1 { label = "flake8" @@ -76,7 +76,7 @@ To address this, the tree was rearranged: } ``` -If using VSCode, this will still run black, flake8 and pyright on file save, but +If using VSCode, this will still run ruff, flake8 and pyright on file save, but for those using other editors and for CI another solution was needed. Enter [pre-commit](https://pre-commit.com/). This allows hooks to be run at `git commit` time on just the files that have changed, as well as on all tracked @@ -113,7 +113,7 @@ The graph now looks like: "sphinx-build" subgraph cluster_1 { label = "pre-commit" - black + ruff subgraph cluster_2 { label = "flake8" "flake8-isort" @@ -124,11 +124,11 @@ The graph now looks like: Now the workflow looks like this: -- Save file, VSCode runs black, flake8 and pyright on it +- Save file, VSCode runs ruff, flake8 and pyright on it - Run 'tox -p' and fix issues until it succeeds -- Commit files and pre-commit runs black and flake8 on them (if the +- Commit files and pre-commit runs ruff and flake8 on them (if the developer had not run tox then this catches some of the most common issues) -- Push to remote and CI runs black, flake8, pyright once on all files +- Push to remote and CI runs ruff, flake8, pyright once on all files (using tox), then pytest multiple times in a test matrix ## Consequences diff --git a/docs/reference/standards.rst b/docs/reference/standards.rst index 711cbbac..d4098737 100644 --- a/docs/reference/standards.rst +++ b/docs/reference/standards.rst @@ -9,7 +9,7 @@ Code Standards The code in this repository conforms to standards set by the following tools: -- black_ for code formatting +- ruff_ for code formatting - flake8_ for style checks - isort_ for import ordering - pyright_ for static type checking diff --git a/template/{% if sphinx %}docs{% endif %}/conf.py.jinja b/template/{% if sphinx %}docs{% endif %}/conf.py.jinja index 95c41f25..daacd00b 100644 --- a/template/{% if sphinx %}docs{% endif %}/conf.py.jinja +++ b/template/{% if sphinx %}docs{% endif %}/conf.py.jinja @@ -106,7 +106,7 @@ inheritance_graph_attrs = {"rankdir": "TB"} # Common links that should be available on every page rst_epilog = """ .. _Diamond Light Source: http://www.diamond.ac.uk -.. _black: https://github.com/psf/black +.. _ruff: https://github.com/astral-sh/ruff .. _ruff: https://beta.ruff.rs/docs/ .. _pyright: https://microsoft.github.io/pyright/#/ .. _pre-commit: https://pre-commit.com/ diff --git a/template/{% if sphinx %}docs{% endif %}/developer/how-to/lint.rst b/template/{% if sphinx %}docs{% endif %}/developer/how-to/lint.rst index 2df258d8..c739f27a 100644 --- a/template/{% if sphinx %}docs{% endif %}/developer/how-to/lint.rst +++ b/template/{% if sphinx %}docs{% endif %}/developer/how-to/lint.rst @@ -1,7 +1,7 @@ Run linting using pre-commit ============================ -Code linting is handled by black_ and ruff_ run under pre-commit_. +Code linting is handled by ruff_ run under pre-commit_. Running pre-commit ------------------ @@ -21,13 +21,9 @@ This will result in pre-commits being enabled on every repo your user clones fro Fixing issues ------------- -If black reports an issue you can tell it to reformat all the files in the +If ruff reports an issue you can tell it to reformat all the files in the repository:: - $ black . - -Likewise with ruff:: - $ ruff --fix . Ruff may not be able to automatically fix all issues; in this case, you will have to fix those manually. @@ -35,5 +31,4 @@ Ruff may not be able to automatically fix all issues; in this case, you will hav VSCode support -------------- -The ``.vscode/settings.json`` will run black formatting as well as -ruff checking on save. Issues will be highlighted in the editor window. +The ``.vscode/settings.json`` will run ruff checking on save. Issues will be highlighted in the editor window. diff --git a/template/{% if sphinx %}docs{% endif %}/developer/reference/standards.rst b/template/{% if sphinx %}docs{% endif %}/developer/reference/standards.rst index 1cc9da82..3722a062 100644 --- a/template/{% if sphinx %}docs{% endif %}/developer/reference/standards.rst +++ b/template/{% if sphinx %}docs{% endif %}/developer/reference/standards.rst @@ -9,7 +9,6 @@ Code Standards The code in this repository conforms to standards set by the following tools: -- black_ for code formatting - ruff_ for style checks - pyright_ for static type checking