Skip to content

Commit

Permalink
docs: Update Black and isort references to Ruff.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <anders@zulip.com>
  • Loading branch information
andersk committed Jul 18, 2024
1 parent 7b8fb01 commit e020878
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Come find us on the [development community chat](https://zulip.com/development-c
[![coverage status](https://img.shields.io/codecov/c/github/zulip/zulip/main.svg)](https://codecov.io/gh/zulip/zulip)
[![Mypy coverage](https://img.shields.io/badge/mypy-100%25-green.svg)][mypy-coverage]
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![GitHub release](https://img.shields.io/github/release/zulip/zulip.svg)](https://github.com/zulip/zulip/releases/latest)
[![docs](https://readthedocs.org/projects/zulip/badge/?version=latest)](https://zulip.readthedocs.io/en/latest/)
Expand Down
19 changes: 7 additions & 12 deletions docs/contributing/code-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ lint checks in parallel, including:
- JavaScript ([ESLint](https://eslint.org/),
[Prettier](https://prettier.io/))
- Python ([mypy](http://mypy-lang.org/),
[ruff](https://github.com/astral-sh/ruff),
[Black](https://github.com/psf/black),
[isort](https://pycqa.github.io/isort/))
[Ruff](https://docs.astral.sh/ruff/))
- templates
- Puppet configuration
- custom checks (e.g., trailing whitespace and spaces-not-tabs)
Expand Down Expand Up @@ -139,15 +137,12 @@ rules about integrating third-party projects.
## Python-specific conventions and practices

- Our Python code is formatted with
[Black](https://github.com/psf/black) and
[isort](https://pycqa.github.io/isort/). The [linter
tool](../testing/linters.md) enforces this by running Black and
isort in check mode, or in write mode with
`tools/lint --only=black,isort --fix`. You may find it helpful to
[integrate Black](https://black.readthedocs.io/en/stable/integrations/editors.html)
and
[isort](https://pycqa.github.io/isort/#installing-isorts-for-your-preferred-text-editor)
with your editor.
[Ruff](https://docs.astral.sh/ruff/). The [linter
tool](../testing/linters.md) enforces this by running Ruff in check
mode, or in write mode with
`tools/lint --only=ruff,ruff-format --fix`. You may find it helpful
to [integrate Ruff](https://docs.astral.sh/ruff/integrations/) with
your editor.
- Don't put a shebang line on a Python file unless it's meaningful to
run it as a script. (Some libraries can also be run as scripts, e.g.,
to run a test suite.)
Expand Down
21 changes: 9 additions & 12 deletions docs/testing/linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ prevent common coding errors.
We borrow some open source tools for much of our linting, and the links
below will direct you to the official documentation for these projects.

- [Black](https://github.com/psf/black)
- [ESLint](https://eslint.org)
- [isort](https://pycqa.github.io/isort/)
- [mypy](http://mypy-lang.org/)
- [Prettier](https://prettier.io/)
- [Puppet](https://puppet.com/) (puppet provides its own mechanism for
validating manifests)
- [ruff](https://github.com/astral-sh/ruff)
- [Ruff](https://docs.astral.sh/ruff/)
- [stylelint](https://github.com/stylelint/stylelint)

Zulip also uses some home-grown code to perform tasks like validating
Expand Down Expand Up @@ -109,8 +107,8 @@ describes our test system in detail.
Most of our lint checks get performed by `./tools/lint`. These include the
following checks:

- Check Python code with ruff.
- Check Python formatting with Black and isort.
- Check Python code with Ruff.
- Check Python formatting with Ruff.
- Check JavaScript and TypeScript code with ESLint.
- Check CSS, JavaScript, TypeScript, and YAML formatting with Prettier.
- Check Python code for custom Zulip rules.
Expand All @@ -131,7 +129,7 @@ The rest of this document pertains to the checks that occur in `./tools/lint`.

Zulip has a script called `lint` that lives in our "tools" directory.
It is the workhorse of our linting system, although in some cases it
dispatches the heavy lifting to other components such as ruff,
dispatches the heavy lifting to other components such as Ruff,
eslint, and other home grown tools.

You can find the source code [here](https://github.com/zulip/zulip/blob/main/tools/lint).
Expand Down Expand Up @@ -176,13 +174,12 @@ sense (e.g., a link in a comment to an extremely long URL).

#### Python code

Our Python code is formatted using Black (using the options in the
`[tool.black]` section of `pyproject.toml`) and isort (using the
options in `.isort.cfg`). The `lint` script enforces this by running
Black and isort in check mode, or in write mode with `--fix`.
Our Python code is formatted using
[Ruff](https://docs.astral.sh/ruff/) (using the options in the
`[tool.ruff]` section of `pyproject.toml`). The `lint` script enforces
this by running Ruff in check mode, or in write mode with `--fix`.

The bulk of our Python linting gets outsourced to the "ruff" tool,
which is configured in the `tool.ruff` section of `pyproject.toml`.
The bulk of our Python linting also gets outsourced to Ruff.

Zulip also has custom regex-based rules that it applies to Python code.
Look for `python_rules` in the source code for `lint`. Note that we
Expand Down
2 changes: 1 addition & 1 deletion tools/setup/emoji/generate_emoji_names
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def main() -> None:
f.write("}\n")

print(
"\n\nDone! You should run the linter to format emoji_names.py with `./tools/lint --fix -m --only black`"
"\n\nDone! You should run the linter to format emoji_names.py with `./tools/lint --fix -m --only ruff-format`"
)


Expand Down

0 comments on commit e020878

Please sign in to comment.