-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document Ruff linting, formatting, and pre-commit
Fixes #518
- Loading branch information
1 parent
7157bef
commit 68183fa
Showing
3 changed files
with
78 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Formatting | ||
========== | ||
|
||
The :obj:`galois` library uses `Ruff <https://docs.astral.sh/ruff/>`_ for static analysis, linting, and code | ||
formatting. | ||
|
||
Install | ||
------- | ||
|
||
First, `ruff` needs to be installed on your system. Easily install it by installing the development dependencies. | ||
|
||
.. code-block:: console | ||
$ python3 -m pip install -r requirements-dev.txt | ||
Configuration | ||
------------- | ||
|
||
The `ruff` configuration is provided in `pyproject.toml`. | ||
|
||
.. literalinclude:: ../../pyproject.toml | ||
:caption: pyproject.toml | ||
:start-at: [tool.ruff] | ||
:end-before: [tool.pytest.ini_options] | ||
:language: toml | ||
|
||
Run the linter | ||
-------------- | ||
|
||
Run the Ruff linter manually from the command line. | ||
|
||
.. code-block:: console | ||
$ python3 -m ruff check . | ||
Run the formatter | ||
----------------- | ||
|
||
Run the Ruff formatter manually from the command line. | ||
|
||
.. code-block:: console | ||
$ python3 -m ruff format --check . | ||
Pre-commit | ||
---------- | ||
|
||
A `pre-commit` configuration file with various hooks is provided in `.pre-commit-config.yaml`. | ||
|
||
.. literalinclude:: ../../.pre-commit-config.yaml | ||
:caption: .pre-commit-config.yaml | ||
:language: yaml | ||
|
||
Enable `pre-commit` by installing the pre-commit hooks. | ||
|
||
.. code-block:: console | ||
$ pre-commit install | ||
Run `pre-commit` on all files. | ||
|
||
.. code-block:: console | ||
$ pre-commit run --all-files | ||
Disable `pre-commit` by uninstalling the pre-commit hooks. | ||
|
||
.. code-block:: console | ||
$ pre-commit uninstall | ||
Run from VS Code | ||
---------------- | ||
|
||
Install the `Ruff extension <https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff>`_ for VS Code. | ||
Included is a VS Code configuration file `.vscode/settings.json`. | ||
VS Code will run the linter and formatter as you view and edit files. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters