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: crates/ruff_python_formatter/README.md
+25-26
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,7 @@
1
1
# Ruff Formatter
2
2
3
3
The Ruff formatter is an extremely fast Python code formatter that ships as part of the `ruff`
4
-
CLI (as of Ruff v0.0.289).
5
-
6
-
The formatter is currently in an **Alpha** state. The Alpha is primarily intended for
7
-
experimentation: our focus is on collecting feedback that we can address prior to a production-ready
8
-
Beta release later this year. (While we're using the formatter in production on our own projects,
9
-
the CLI, configuration options, and code style may change arbitrarily between the Alpha and Beta.)
10
-
11
-
[_We'd love to hear your feedback._](https://github.com/astral-sh/ruff/discussions/7310)
4
+
CLI.
12
5
13
6
## Goals
14
7
@@ -30,7 +23,7 @@ For details, see [Black compatibility](#black-compatibility).
30
23
31
24
## Getting started
32
25
33
-
The Ruff formatter shipped in an Alpha state as part of Ruff v0.0.289.
26
+
The Ruff formatter is available in Beta as of Ruff v0.1.2.
34
27
35
28
### CLI
36
29
@@ -46,41 +39,48 @@ Arguments:
46
39
[FILES]... List of files or directories to format
47
40
48
41
Options:
49
-
--check Avoid writing any formatted files back; instead, exit with a non-zero status code if any files would have been modified, and zero otherwise
50
-
--config <CONFIG> Path to the `pyproject.toml` or `ruff.toml` file to use for configuration
51
-
-h, --help Print help
52
-
53
-
File selection:
54
-
--respect-gitignore Respect file exclusions via `.gitignore` and other standard ignore files
55
-
--force-exclude Enforce exclusions, even for paths passed to Ruff directly on the command-line
42
+
--check
43
+
Avoid writing any formatted files back; instead, exit with a non-zero status code if any files would have been modified, and zero otherwise
44
+
--diff
45
+
Avoid writing any formatted files back; instead, exit with a non-zero status code and the difference between the current file and how the formatted file would look like
46
+
--config <CONFIG>
47
+
Path to the `pyproject.toml` or `ruff.toml` file to use for configuration
48
+
--target-version <TARGET_VERSION>
49
+
The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312]
50
+
--preview
51
+
Enable preview mode; enables unstable formatting. Use `--no-preview` to disable
52
+
-h, --help
53
+
Print help
56
54
57
55
Miscellaneous:
56
+
-n, --no-cache Disable cache reads
57
+
--cache-dir <CACHE_DIR> Path to the cache directory [env: RUFF_CACHE_DIR=]
58
58
--isolated Ignore all configuration files
59
59
--stdin-filename <STDIN_FILENAME> The name of the file when passing it through stdin
60
60
61
+
File selection:
62
+
--respect-gitignore Respect file exclusions via `.gitignore` and other standard ignore files. Use `--no-respect-gitignore` to disable
63
+
--exclude <FILE_PATTERN> List of paths, used to omit files and/or directories from analysis
64
+
--force-exclude Enforce exclusions, even for paths passed to Ruff directly on the command-line. Use `--no-force-exclude` to disable
65
+
61
66
Log levels:
62
67
-v, --verbose Enable verbose logging
63
68
-q, --quiet Print diagnostics, but nothing else
64
69
-s, --silent Disable all logging (but still exit with status code "1" upon detecting diagnostics)
65
70
```
66
71
67
-
Note: `ruff format` is currently hidden by default and will not be visible when running
68
-
`ruff --help`.
69
-
70
72
Similar to Black, running `ruff format /path/to/file.py` will format the given file or directory
71
73
in-place, while `ruff format --check /path/to/file.py` will avoid writing any formatted files back,
72
74
instead exiting with a non-zero status code if any files are not already formatted.
73
75
74
76
### VS Code
75
77
76
-
As of `v2023.36.0`, the [Ruff VS Code extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff)
77
-
ships with support for the Ruff formatter. To enable formatting capabilities, set the
78
-
`ruff.enableExperimentalFormatter` setting to `true` in your `settings.json`, and mark the Ruff
78
+
As of `v2023.44.0`, the [Ruff VS Code extension](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff)
79
+
ships with full support for the Ruff formatter. To enable formatting capabilities, mark the Ruff
79
80
extension as your default Python formatter:
80
81
81
82
```json
82
83
{
83
-
"ruff.enableExperimentalFormatter": true,
84
84
"[python]": {
85
85
"editor.defaultFormatter": "charliermarsh.ruff"
86
86
}
@@ -92,7 +92,6 @@ on-save by adding `"editor.formatOnSave": true` to your `settings.json`:
0 commit comments