Skip to content

Commit ff1d7b5

Browse files
author
Magnus Larsen
committed
[feat] Add setting for enabling/disabling Preview rules
1 parent be27747 commit ff1d7b5

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The plugin follows [python-lsp-server's
6262
configuration](https://github.com/python-lsp/python-lsp-server/#configuration). These are
6363
the valid configuration keys:
6464

65-
- `pylsp.plugins.ruff.enabled`: boolean to enable/disable the plugin. `true` by default.
65+
- `pylsp.plugins.ruff.enabled`: Boolean to enable/disable the plugin. `true` by default.
6666
- `pylsp.plugins.ruff.config`: Path to optional `pyproject.toml` file.
6767
- `pylsp.plugins.ruff.exclude`: Exclude files from being checked by `ruff`.
6868
- `pylsp.plugins.ruff.executable`: Path to the `ruff` executable. Uses `os.executable -m "ruff"` by default.
@@ -73,7 +73,8 @@ the valid configuration keys:
7373
- `pylsp.plugins.ruff.select`: List of error codes to enable.
7474
- `pylsp.plugins.ruff.extendSelect`: Same as select, but append to existing error codes.
7575
- `pylsp.plugins.ruff.format`: List of error codes to fix during formatting. The default is `["I"]`, any additional codes are appended to this list.
76-
- `pylsp.plugins.ruff.unsafeFixes`: boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
76+
- `pylsp.plugins.ruff.unsafeFixes`: Boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
77+
- `pylsp.plugins.ruff.preview`: Boolean that enables/disables rules & fixes that are marked "preview" by `ruff`. `false` by default.
7778
- `pylsp.plugins.ruff.severities`: Dictionary of custom severity levels for specific codes, see [below](#custom-severities).
7879

7980
For more information on the configuration visit [Ruff's homepage](https://beta.ruff.rs/docs/configuration/).

pylsp_ruff/plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ def build_arguments(
533533
if settings.line_length:
534534
args.append(f"--line-length={settings.line_length}")
535535

536+
if settings.preview:
537+
args.append("--preview")
538+
536539
if settings.unsafe_fixes:
537540
args.append("--unsafe-fixes")
538541

pylsp_ruff/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class PluginSettings:
2323

2424
format: Optional[List[str]] = None
2525

26+
preview: bool = False
2627
unsafe_fixes: bool = False
2728

2829
severities: Optional[Dict[str, str]] = None

0 commit comments

Comments
 (0)