Skip to content

Commit

Permalink
Update the linters page. (#276)
Browse files Browse the repository at this point in the history
* Fixes #259.
* Fixes the ordering part of  #249 for this page.
  • Loading branch information
samcunliffe authored Jan 23, 2024
1 parent 3342e23 commit 18d1551
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions docs/pages/linting.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,25 @@ layout: default

# Linting

See [here for example configuration](https://github.com/UCL-ARC/python-tooling/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/.pre-commit-config.yaml) for some of these.
See [here for an example configuration](https://github.com/UCL-ARC/python-tooling/blob/main/%7B%7Bcookiecutter.project_slug%7D%7D/.pre-commit-config.yaml) for some of these.

## Code formatting

| Name | Short description | 🚦 | Used by |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| [ruff-format](https://github.com/astral-sh/ruff) | Like `black` but super fast. | 🟢 | |
| [isort](https://pycqa.github.io/isort/) | Sorts imports alphabetically, splits into first/third party, works on python & cython code. | 🟢 | |
| [pre-commit](https://pre-commit.com/) | Universal tool which performs a git hook on commit, allows you to run linters/formatters on any code. A tool to automatically run many of the tools listed below. | 🟢 | [DiRAC](https://github.com/UCL-ARC/dirac-swift-api), [RRED](https://github.com/UCL-ARC/rred-reports), [Crabs Exploration](https://github.com/SainsburyWellcomeCentre/crabs-exploration) |
| [ruff](https://github.com/astral-sh/ruff) | A very fast linter which incorporates a range of other linters. | 🟢 | [DiRAC](https://github.com/UCL-ARC/dirac-swift-api), [RRED](https://github.com/UCL-ARC/rred-reports), [Crabs Exploration](https://github.com/SainsburyWellcomeCentre/crabs-exploration) |
| [toml-sort](https://toml-sort.readthedocs.io/en/latest/) | Sorts TOML files which are now part of PEP 8. | 🟢 | |
| [black](https://black.readthedocs.io/en/stable/) | Opinionated formatter, defaults to 88 characters per line. | 🟠 | [DiRAC](https://github.com/UCL-ARC/dirac-swift-api), [Crabs Exploration](https://github.com/SainsburyWellcomeCentre/crabs-exploration), [autodE](https://github.com/duartegroup/autodE) |
| [autopep8](https://github.com/hhatto/autopep8) | Formatter which conforms to PEP 8. | 🟠 | |
| [pycodestyle](https://pycodestyle.pycqa.org/en/latest/) | Linter which checks for errors. | 🟠 | |
| [pyflakes](https://github.com/PyCQA/pyflakes) | Linter which checks for errors. | 🟠 | |
| [pylint](https://pylint.readthedocs.io/en/latest/) | Linter which checks for errors. | 🟠 | |
| [sourcery](https://sourcery.ai/) | An AI code reviewer which simplifies code, has a free version but can pay for fancier features. | 🟠 | |
| [yapf](https://github.com/google/yapf) | Google formatter. | 🟠 | |
| [flake8](https://flake8.pycqa.org/en/latest/) | Linter which complains if code doesn't follow a rule. Does not support modern `pyproject.toml` configuration. | 🔴 | |

<details>
<summary> 🟢 explanation</summary>

We recommend a suite of 🟢 tools that we've used and work well together.

- Pre-commit is a useful framework tool to list several linters and run it automatically. It can be used to run all of our recommended linters.

- `black` is a nice _"no need to think"_ code formatter. If you have your own opinions about code style you might not like this. But it's widely used by almost all ARC python projects.

</details>

<details>
<summary> 🔴 explanation</summary>

Flake8 is not recommended because it doesn't support `pyproject.toml` and [seemingly won't](https://github.com/PyCQA/flake8/issues/234#issuecomment-1206730688). There are now better and more flexible tools available.

</details>
| Name | Short description | 🚦 | Used by |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| [pre-commit](https://pre-commit.com/) | Universal tool which performs a git hook on commit, allows you to run linters/formatters on any code. A tool to automatically run many of the tools listed below. | 🟢 | [DiRAC](https://github.com/UCL-ARC/dirac-swift-api), [RRED](https://github.com/UCL-ARC/rred-reports), [Crabs Exploration](https://github.com/SainsburyWellcomeCentre/crabs-exploration) |
| [ruff-format](https://github.com/astral-sh/ruff) | A drop-in replacement for `black` (and also super fast). A nice "no-need to think" code formatter. If you have your own opinions about code style, you might not like this. | 🟢 | |
| [ruff](https://github.com/astral-sh/ruff) | A fast linter which incorporates a range of other linters. Notably [isort](https://pycqa.github.io/isort/) can be included as a [ruff rule](https://docs.astral.sh/ruff/rules/) (which we recommend). | 🟢 | [DiRAC](https://github.com/UCL-ARC/dirac-swift-api), [RRED](https://github.com/UCL-ARC/rred-reports), [Crabs Exploration](https://github.com/SainsburyWellcomeCentre/crabs-exploration) |
| [toml-sort](https://toml-sort.readthedocs.io/en/latest/) | Sorts TOML files which are now part of PEP 8. | 🟢 | |
| [autopep8](https://github.com/hhatto/autopep8) | Formatter which conforms to PEP 8. | 🟠 | |
| [black](https://black.readthedocs.io/en/stable/) | Opinionated formatter, defaults to 88 characters per line. Widely used, but we now recommend `ruff-format` in its place. | 🟠 | [DiRAC](https://github.com/UCL-ARC/dirac-swift-api), [Crabs Exploration](https://github.com/SainsburyWellcomeCentre/crabs-exploration), [autodE](https://github.com/duartegroup/autodE) |
| [isort](https://pycqa.github.io/isort/) | Sorts imports alphabetically, splits into first/third party, works on python & cython code. We recommend this, but it can be included in `ruff`, which is simpler. | 🟠 | |
| [pycodestyle](https://pycodestyle.pycqa.org/en/latest/) | Linter which checks for errors. | 🟠 | |
| [pyflakes](https://github.com/PyCQA/pyflakes) | Linter which checks for errors. | 🟠 | |
| [pylint](https://pylint.readthedocs.io/en/latest/) | Linter which checks for errors. | 🟠 | |
| [sourcery](https://sourcery.ai/) | An AI code reviewer which simplifies code, has a free version but can pay for fancier features. | 🟠 | |
| [yapf](https://github.com/google/yapf) | Google formatter. | 🟠 | |
| [flake8](https://flake8.pycqa.org/en/latest/) | Linter which complains if code doesn't follow a rule. Does not support modern `pyproject.toml` configuration. | 🔴 | |

## Type checking

Expand Down

0 comments on commit 18d1551

Please sign in to comment.