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
Improve documentation of the preview mode (#10168)
## Summary
This PR was prompted by the discussion in #10153.
It adds CLI tab examples next to the `pyproject.toml` and `ruff.toml`
examples. It should be helpful for users wanting to try out the preview
mode without modifying or creating a `.toml` file.
It also adds a paragraph to try to make the effect of the preview mode
less confusing.
Copy file name to clipboardExpand all lines: docs/preview.md
+43-6Lines changed: 43 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,9 @@
3
3
Ruff includes an opt-in preview mode to provide an opportunity for community feedback and increase confidence that
4
4
changes are a net-benefit before enabling them for everyone.
5
5
6
-
Preview mode enables a collection of newer lint rules, fixes, and formatter style changes that are
7
-
considered experimental or unstable,.
6
+
Preview mode enables a collection of unstable features such as new lint rules and fixes, formatter style changes, interface updates, and more. Warnings about deprecated features may turn into errors when using preview mode.
7
+
8
+
Enabling preview mode does not on its own enable all preview rules. See the [rules section](#using-rules-that-are-in-preview) for details on selecting preview rules.
8
9
9
10
## Enabling preview mode
10
11
@@ -27,6 +28,13 @@ Preview mode can be configured separately for linting and formatting (requires R
27
28
preview = true
28
29
```
29
30
31
+
=== "CLI"
32
+
33
+
```console
34
+
ruff check --preview
35
+
```
36
+
37
+
30
38
To enable preview style formatting without enabling any preview lint rules:
31
39
32
40
=== "pyproject.toml"
@@ -43,11 +51,16 @@ To enable preview style formatting without enabling any preview lint rules:
43
51
preview = true
44
52
```
45
53
54
+
=== "CLI"
55
+
56
+
```console
57
+
ruff format --preview
58
+
```
59
+
46
60
## Using rules that are in preview
47
61
48
62
If a rule is marked as preview, it can only be selected if preview mode is enabled. For example, consider a
49
-
hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding following to your
50
-
config file:
63
+
hypothetical rule, `HYP001`. If `HYP001` were in preview, it would _not_ be enabled by adding it to the selected rule set.
51
64
52
65
=== "pyproject.toml"
53
66
@@ -63,6 +76,13 @@ config file:
63
76
extend-select = ["HYP001"]
64
77
```
65
78
79
+
=== "CLI"
80
+
81
+
```console
82
+
ruff check --extend-select HYP001
83
+
```
84
+
85
+
66
86
It also would _not_ be enabled by selecting the `HYP` category, like so:
67
87
68
88
=== "pyproject.toml"
@@ -79,6 +99,13 @@ It also would _not_ be enabled by selecting the `HYP` category, like so:
79
99
extend-select = ["HYP"]
80
100
```
81
101
102
+
=== "CLI"
103
+
104
+
```console
105
+
ruff check --extend-select HYP
106
+
```
107
+
108
+
82
109
Similarly, it would _not_ be enabled via the `ALL` selector:
83
110
84
111
=== "pyproject.toml"
@@ -95,7 +122,13 @@ Similarly, it would _not_ be enabled via the `ALL` selector:
95
122
select = ["ALL"]
96
123
```
97
124
98
-
However, it would be enabled in any of the above cases if you enabled preview in your configuration file:
125
+
=== "CLI"
126
+
127
+
```console
128
+
ruff check --select ALL
129
+
```
130
+
131
+
However, it _would_ be enabled in any of the above cases if you enabled preview mode:
99
132
100
133
=== "pyproject.toml"
101
134
@@ -113,7 +146,11 @@ However, it would be enabled in any of the above cases if you enabled preview in
113
146
preview = true
114
147
```
115
148
116
-
Or, if you provided the `--preview` CLI flag.
149
+
=== "CLI"
150
+
151
+
```console
152
+
ruff check --extend-select HYP --preview
153
+
```
117
154
118
155
To see which rules are currently in preview, visit the [rules reference](rules.md).
0 commit comments