Skip to content

Commit 1499311

Browse files
committed
Update Python code style guidelines regarding usage of ruff
1 parent 32f1b6e commit 1499311

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

contributing/development/code_style_guidelines.rst

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -267,35 +267,34 @@ Python
267267
Godot's SCons buildsystem is written in Python, and various scripts included
268268
in the source tree are also using Python.
269269

270-
For those, we follow the `Black style guide <https://github.com/psf/black#the-black-code-style>`__.
271-
Blacken your Python changes using `Black <https://pypi.org/project/black/>`__.
270+
For those, we use the `Ruff linter and code formatter <https://docs.astral.sh/ruff/>`__.
272271

273-
Using black locally
272+
Using ruff locally
274273
~~~~~~~~~~~~~~~~~~~
275274

276-
First of all, you will need to install Black. Black requires Python 3.7+ to run.
275+
First of all, you will need to install Ruff. Ruff requires Python 3.7+ to run.
277276

278277
Installation
279278
^^^^^^^^^^^^
280279

281-
Here's how to install black:
280+
Here's how to install ruff:
282281

283282
::
284283

285-
pip3 install black --user
284+
pip3 install ruff --user
286285

287286

288-
You then have different possibilities to apply black to your changes:
287+
You then have different possibilities to apply ruff to your changes:
289288

290289
Manual usage
291290
^^^^^^^^^^^^
292291

293-
You can apply ``black`` manually to one or more files with the following
292+
You can apply ``ruff`` manually to one or more files with the following
294293
command:
295294

296295
::
297296

298-
black -l 120 <path/to/file(s)>
297+
ruff -l 120 <path/to/file(s)>
299298

300299
- ``-l 120`` means that the allowed number of characters per line is 120.
301300
This number was agreed upon by the developers.
@@ -307,8 +306,8 @@ Pre-commit hook
307306
~~~~~~~~~~~~~~~
308307

309308
For ease of use, we provide hooks for Git with the `pre-commit <https://pre-commit.com/>`__
310-
Python framework that will run ``black`` automatically on all your commits with the
311-
correct version of ``black``.
309+
Python framework that will run ``ruff`` automatically on all your commits with the
310+
correct version of ``ruff``.
312311
To set up:
313312

314313
::
@@ -319,7 +318,7 @@ To set up:
319318

320319
You can also run the hook manually with ``pre-commit run``.
321320

322-
.. note::
321+
.. note::
323322

324323
Previously, we supplied a hook in the folder ``misc/hooks``. If you copied the
325324
script manually, these hooks should still work, but symlinks will be broken.
@@ -331,8 +330,8 @@ Editor integration
331330
^^^^^^^^^^^^^^^^^^
332331

333332
Many IDEs or code editors have beautifier plugins that can be configured to run
334-
black automatically, for example, each time you save a file. For details, you can
335-
check `Black editor integration <https://github.com/psf/black#editor-integration>`__.
333+
ruff automatically, for example, each time you save a file. For details, you can
334+
check `Ruff Integrations <https://docs.astral.sh/ruff/integrations/>`__.
336335

337336
Comment style guide
338337
-------------------

0 commit comments

Comments
 (0)