Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to remove flake8, isort mentions and add ruff #502

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 1 addition & 7 deletions docs/plugins/virtual_environment_docs/4-developer-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,12 +25,6 @@ These _check_ your code.
These _auto-modify_ your code.
* [black](https://github.com/psf/black)
melissawm marked this conversation as resolved.
Show resolved Hide resolved
Forces code to follow specific style, indentations, etc...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using ruff-format, not black now.
It is slimier to black, but not equivalent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right -I only see one rule though

https://github.com/napari/napari/blob/b9dc8dca1e1afa7567586e7ffa7a36cc7cd9fb6f/pyproject.toml#L245

so I'll again just point people to the pyproject.toml in case there are future updates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melissawm If you scroll down from your link, ruff is performing all of the task that you had in the original text since it is a drop-in replacement for these tools. Perhaps link out to ruff docs: https://docs.astral.sh/ruff/linter/#the-ruff-linter

* [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
Loading