From 142ac9a29857a5db5fcc5c3960c3d4b2c1c83073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Melissa=20Weber=20Mendon=C3=A7a?= Date: Fri, 8 Nov 2024 01:57:34 -0300 Subject: [PATCH] Update docs to remove flake8, isort mentions and add ruff (#502) # References and relevant issues Partially addresses #377. Mentions to setup.cfg remain in the plugin docs which need to be updated separately. # Description Updates mentions of flake8 and isort by ruff. Also removes some explicit mentions of ignore rules since these get out of date quickly and can be checked directly in the pyproject.toml file. --------- Co-authored-by: Draga Doncila Pop <17995243+DragaDoncila@users.noreply.github.com> --- docs/developers/contributing/dev_install.md | 21 +++++++------------ docs/developers/coredev/core_dev_guide.md | 4 ++-- .../4-developer-tools.md | 10 ++------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/docs/developers/contributing/dev_install.md b/docs/developers/contributing/dev_install.md index b128d3c7..92b3ab84 100644 --- a/docs/developers/contributing/dev_install.md +++ b/docs/developers/contributing/dev_install.md @@ -73,7 +73,7 @@ In order to make changes to `napari`, you will need to [fork](https://docs.githu Note that in this last case you will need to install your Qt backend separately. 5. We use [`pre-commit`](https://pre-commit.com) to format code with - [`black`](https://github.com/psf/black) and lint with + [`ruff-format`](https://docs.astral.sh/ruff/formatter/) and lint with [`ruff`](https://github.com/astral-sh/ruff) automatically prior to each commit. To minimize test errors when submitting pull requests, please install `pre-commit` in your environment as follows: @@ -82,20 +82,15 @@ In order to make changes to `napari`, you will need to [fork](https://docs.githu pre-commit install ``` - Upon committing, your code will be formatted according to our [`black` - configuration](https://github.com/napari/napari/blob/main/pyproject.toml), which includes the settings - `skip-string-normalization = true` and `max-line-length = 79`. To learn more, - see [`black`'s documentation](https://black.readthedocs.io/en/stable/). + Upon committing, your code will be formatted according to our [`ruff-format` + configuration](https://github.com/napari/napari/blob/main/pyproject.toml). Code will also be linted to enforce the stylistic and logistical rules specified - in our [`flake8` configuration](https://github.com/napari/napari/blob/main/pyproject.toml), which currently ignores - [E203](https://lintlyci.github.io/Flake8Rules/rules/E203.html), - [E501](https://lintlyci.github.io/Flake8Rules/rules/E501.html), - [W503](https://lintlyci.github.io/Flake8Rules/rules/W503.html) and - [C901](https://lintlyci.github.io/Flake8Rules/rules/C901.html). For information - on any specific flake8 error code, see the [Flake8 - Rules](https://lintlyci.github.io/Flake8Rules/). You may also wish to refer to - the [PEP 8 style guide](https://peps.python.org/pep-0008/). + in the `[tool.ruff]` section of + [our `pyproject.toml` file](https://github.com/napari/napari/blob/main/pyproject.toml). + For information on any specific `ruff` error code, see the + [Ruff Rules](https://docs.astral.sh/ruff/rules/). You may also wish to refer + to the [PEP 8 style guide](https://peps.python.org/pep-0008/). If you wish to tell the linter to ignore a specific line use the `# noqa` comment along with the specific error code (e.g. `import sys # noqa: E402`) but diff --git a/docs/developers/coredev/core_dev_guide.md b/docs/developers/coredev/core_dev_guide.md index f386b963..5505f287 100644 --- a/docs/developers/coredev/core_dev_guide.md +++ b/docs/developers/coredev/core_dev_guide.md @@ -174,8 +174,8 @@ As a core member, you should be familiar with the following napari guides: [NumPy documentation guide](https://numpy.org/devdocs/dev/howto-docs.html#documentation-style) for docstring conventions. - [`pre-commit`](https://pre-commit.com) hooks for autoformatting. -- [`black`](https://github.com/psf/black) autoformatting. -- [`flake8`](https://github.com/PyCQA/flake8) linting. +- [`ruff-format`](https://docs.astral.sh/ruff/formatter/) autoformatting. +- [`ruff`](https://github.com/astral-sh/ruff) linting. ### Social resources diff --git a/docs/plugins/virtual_environment_docs/4-developer-tools.md b/docs/plugins/virtual_environment_docs/4-developer-tools.md index 82d67a8c..f0909a61 100644 --- a/docs/plugins/virtual_environment_docs/4-developer-tools.md +++ b/docs/plugins/virtual_environment_docs/4-developer-tools.md @@ -15,7 +15,7 @@ Many are very helpful, but they do take a little time to learn. The more time yo ### Linting tools These _check_ your code. -* [flake8](https://flake8.pycqa.org/) - checks various code style conventions, unused variables, line spacings, etc… +* [ruff](https://github.com/astral-sh/ruff) - checks various code style conventions, unused variables, line spacings, etc… * [mypy](https://github.com/python/mypy) - Static type checker: enforces proper usage of types. - Super useful once you get the hang of it, but definitely an intermediate-advanced tool. @@ -23,14 +23,8 @@ These _check_ your code. ### Formatting tools These _auto-modify_ your code. -* [black](https://github.com/psf/black) +* [ruff-formatter](https://docs.astral.sh/ruff/formatter/) Forces code to follow specific style, indentations, etc... -* [autoflake](https://github.com/PyCQA/autoflake) - Auto-fixes some flake8 failures. -* [isort](https://github.com/PyCQA/isort) - Auto-sorts and formats your imports. -* [setup-cfg-fmt](https://github.com/asottile/setup-cfg-fmt) - Sorts and enforces conventions in setup.cfg. ### Pre-commit tools * [pre-commit](https://pre-commit.com/), runs all your checks each time you run git commit, preventing bad code from ever getting checked in.