You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-42Lines changed: 7 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -388,61 +388,26 @@ _Coming soon_
388
388
389
389
In all our Django projects we use:
390
390
391
-
-[flake8](https://flake8.pycqa.org/en/latest/) - a linter that ensures we follow the PEP8 conventions.
392
-
-[black](https://github.com/psf/black) - a code formatter that ensures we have the same code style everywhere.
393
-
-[isort](https://github.com/PyCQA/isort) - a code formatter that ensures we have the same import style everywhere.
391
+
-[ruff](https://docs.astral.sh/ruff/) - an extremely fast Python linter and code formatter, written in Rust.
394
392
-[pre-commit](https://pre-commit.com/) - a tool that triggers the linters before each commit.
395
393
396
394
To make sure all of the above tools work in symbiosis, you'd need to add some configuration:
397
395
398
396
1. Add `.pre-commit-config.yaml` file to the root of your project. There you can add the instructions for `pre-commit`
399
-
2. Add `pyproject.toml` file to the root of your project. There you can add the `black` config. **NOTE:**`black`[does not respect any other config files.](https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html)
400
-
3. Add the following to `setup.cfg` for the `isort` config:
401
-
402
-
```
403
-
[isort]
404
-
profile = black
405
-
```
406
-
407
-
This will tell `isort` to follow the `black` guidelines.
408
-
409
-
```
410
-
[isort]
411
-
filter_files = true
412
-
skip_glob = */migrations/*
413
-
```
414
-
415
-
This will tell `pre-commit` to respect the `isort` config.
416
-
417
-
4. You can add a custom `flake8` configuration to `setup.cfg` as well. We usually have the following config in all our projects:
418
-
419
-
```
420
-
[flake8]
421
-
max-line-length = 120
422
-
extend-ignore = E203
423
-
exclude =
424
-
.git,
425
-
__pycache__,
426
-
*/migrations/*
427
-
```
428
-
429
-
5. Make sure the linters are run against each PR on your CI. This is the config you need if you use GH actions:
397
+
2. Add `pyproject.toml` file to the root of your project. There you can add the `ruff` config.
398
+
3. Make sure the linters are run against each PR on your CI. This is the config you need if you use GH actions:
430
399
431
400
```
432
401
build:
433
402
runs-on: ubuntu-latest
434
403
steps:
435
-
- name: Run isort
436
-
uses: isort/isort-action@master
437
-
- name: Run black
438
-
uses: psf/black@stable
439
-
- name: Run flake8
440
-
run: flake8
404
+
- name: Run ruff
405
+
uses: chartboost/ruff-action@v1
441
406
```
442
407
443
-
6. Last but not least, we highly recommend you to setup you editor to run `black` and `isort` every time you save a new Python file.
408
+
4. Last but not least, we highly recommend you to setup you editor to run `ruff` every time you save a new Python file.
444
409
445
410
In order to test if your local setup is up to date, you can either:
446
411
447
412
1. Try making a commit, to see if `pre-commit` is going to be triggered.
448
-
1. Or run `black --check .` and `isort --check .` in the project root directory.
413
+
2. Or run `ruff check .` in the project root directory.
0 commit comments