Skip to content

Commit 307b0a5

Browse files
rhttpike3
authored andcommitted
Replace Black with ruff format
See https://astral.sh/blog/the-ruff-formatter, with `ruff format` being 30x faster.
1 parent 3f6a6b6 commit 307b0a5

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

.github/workflows/build_lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ jobs:
8484
uses: actions/setup-python@v4
8585
with:
8686
python-version: "3.12"
87-
- run: pip install black[jupyter]
88-
- name: Lint with black
89-
run: black --check --exclude=mesa/cookiecutter-mesa/* .
87+
- run: pip install ruff~=0.1.1 # Update periodically
88+
- name: Lint with ruff format
89+
run: ruff format --check .

.pre-commit-config.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ ci:
33
autofix_prs: false
44

55
repos:
6-
- repo: https://github.com/psf/black
7-
rev: 23.10.1
8-
hooks:
9-
- id: black-jupyter
10-
exclude: ^mesa/cookiecutter-mesa/
6+
- repo: https://github.com/astral-sh/ruff-pre-commit
7+
# Ruff version.
8+
rev: v0.1.5
9+
hooks:
10+
# Run the linter.
11+
- id: ruff
12+
types_or: [ python, pyi, jupyter ]
13+
# Run the formatter.
14+
- id: ruff-format
15+
types_or: [ python, pyi, jupyter ]
1116
- repo: https://github.com/asottile/pyupgrade
1217
rev: v3.15.0
1318
hooks:

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ We test by implementing simple models and through traditional unit tests in the
8080
8181
py.test --cov=mesa tests/
8282
83-
With respect to code standards, we follow `PEP8`_ and the `Google Style Guide`_. We recommend to use `black`_ as an automated code formatter. You can automatically format your code using `pre-commit`_, which will prevent `git commit` of unstyled code and will automatically apply black style so you can immediately re-run `git commit`. To set up pre-commit run the following commands:
83+
With respect to code standards, we follow `PEP8`_ and the `Google Style Guide`_. We use `ruff format`_ (a more performant alternative to `black`) as an automated code formatter. You can automatically format your code using `pre-commit`_, which will prevent `git commit` of unstyled code and will automatically apply black style so you can immediately re-run `git commit`. To set up pre-commit run the following commands:
8484

8585
.. code-block:: bash
8686

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ dynamic = ["version"]
5252

5353
[project.optional-dependencies]
5454
dev = [
55-
"black",
5655
"ruff~=0.1.1", # Update periodically
5756
"coverage",
5857
"pytest >= 4.6",
@@ -132,6 +131,7 @@ extend-ignore = [
132131
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` TODO
133132
"S310", # Audit URL open for permitted schemes. Allowing use of `file:` or custom schemes is often unexpected.
134133
"S603", # `subprocess` call: check for execution of untrusted input
134+
"ISC001", # ruff format asks to disable this feature
135135
]
136136
extend-exclude = ["docs", "build"]
137137
# Hardcode to Python 3.8.

0 commit comments

Comments
 (0)