Skip to content

Commit

Permalink
Update docs to remove flake8, isort mentions and add ruff (#502)
Browse files Browse the repository at this point in the history
# 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>
  • Loading branch information
melissawm and DragaDoncila authored Nov 8, 2024
1 parent f515058 commit 142ac9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
21 changes: 8 additions & 13 deletions docs/developers/contributing/dev_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/developers/coredev/core_dev_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 2 additions & 8 deletions docs/plugins/virtual_environment_docs/4-developer-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ 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.
- Along with high test coverage, probably the best time-saver and project robustness tool.

### 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.
Expand Down

0 comments on commit 142ac9a

Please sign in to comment.