|
1 | 1 | Auto-formatters |
2 | 2 | --------------- |
3 | 3 |
|
4 | | -Autoformatters are very simple tools to do just a one thing: |
5 | | -reformat some basic stuff in your code like quotes, commas, and line length. |
| 4 | +List of supported tools. |
6 | 5 |
|
7 | | -The difference between a linter and auto-formatter is huge: |
8 | 6 |
|
9 | | -- auto-formatters pretties your code a little bit |
10 | | -- linters force you to write beautiful and correct code |
| 7 | +ruff |
| 8 | +~~~~ |
11 | 9 |
|
12 | | -For example, auto-formatters won't tell you that your code is too complex. |
13 | | -When your linter will (in case it is a good linter). |
| 10 | +Fully supported. |
| 11 | +You can run ``ruff check && ruff format`` and there |
| 12 | +should be no conflicts with ``WPS`` at all. |
14 | 13 |
|
15 | | -Autoformatters are also useless |
16 | | -when dealing with rewriting actually bad code. |
17 | | -Like code with bad variable names, unreachable branches, |
18 | | -statements that have no effect. |
| 14 | +But, ``wemake-python-styleguide`` can and will find additional |
| 15 | +problems that ``ruff`` missed. |
19 | 16 |
|
20 | | -We in ``wemake.services`` believe that these kind of tools are not required, |
21 | | -because a good linter will just not let your badly formatted code pass the CI, |
22 | | -so there would be no junk to reformat! |
23 | | -All code is perfectly formatted all the time. |
24 | | - |
25 | | -Rely on strict linters, not auto-formatters. |
26 | | - |
27 | | -However, if you still want to use some autoformatter |
28 | | -together with ``wemake-python-styleguide`` |
29 | | -we have made some research to help you! |
30 | 17 |
|
31 | 18 | isort |
32 | 19 | ~~~~~ |
33 | 20 |
|
34 | | -``isort`` is a great tool to sort your imports. |
35 | | -We already use it to validate that your imports are correct. |
36 | | -We recommend to use ``isort`` and officially |
37 | | -and support it in a way that all |
38 | | -valid ``wemake-python-styleguide`` code is valid ``isort`` code. |
39 | | -But, **not the other way around**. |
40 | | - |
41 | | -You might be required to refactor your code manually after ``isort`` |
42 | | -reformat to make ``wemake-python-styleguide`` happy. |
43 | | - |
44 | | -``isort`` can also `be invoked <https://github.com/timothycrosley/isort#using-isort>`_ |
45 | | -as a command line tool to fix all your import problems for you. |
46 | | - |
47 | | -We recommend to run ``isort``. They are also compatible. |
| 21 | +We support ``isort``, but we recommend to use ``ruff`` instead. |
| 22 | +See https://docs.astral.sh/ruff/rules/#isort-i |
48 | 23 |
|
49 | | -There are also plugins for IDEs to run ``isort`` on safe: |
50 | | - |
51 | | -- https://github.com/timothycrosley/isort/wiki/isort-Plugins |
52 | | -- https://code.visualstudio.com/docs/python/editing |
53 | | - |
54 | | -You can find the configuration we use in ``setup.cfg`` in this repository. |
55 | 24 |
|
56 | 25 | black |
57 | 26 | ~~~~~ |
58 | 27 |
|
59 | | -``wemake-python-styleguide`` is not compatible with ``black``. |
60 | | -Let's go deeper and see why. |
61 | | - |
62 | | -``black`` itself is actually not compatible with ``PEP8`` and ``flake8`` |
63 | | -(`docs <https://black.readthedocs.io/en/stable/the_black_code_style.html?highlight=flake8>`_), |
64 | | -that's why it is not compatible with ``wemake-python-styleguide`` either. |
65 | | -Here are the violations that ``black`` produces: |
66 | | - |
67 | | -- Quotes: for some reasons ``black`` uses ``"`` |
68 | | - that almost no one uses in the ``python`` world |
69 | | -- Trailing commas: ``black`` strips trailing commas and this makes |
70 | | - adding new code harder to review, since your ``git diff`` is polluted |
71 | | - by a comma change, the sad thing that trailing commas as a best-practice |
72 | | - are quite popular in ``python`` code |
73 | | -- Line length. Violating rules by 10%-15% is not ok. |
74 | | - You either violate them or not. ``black`` violates line-length rules. |
75 | | - |
76 | | -And there's no configuration to fix it! |
77 | | -Shame, that official ``python-org`` product violates the community standards |
78 | | -and not enforcing them. |
| 28 | +Is supported since ``1.0.0``, but we recommend to use ``ruff format`` instead. |
0 commit comments