Skip to content

Commit 5d7338d

Browse files
authored
Add setting for enabling/disabling Preview rules (#54)
1 parent e5091cb commit 5d7338d

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
@@ -68,7 +68,7 @@ The plugin follows [python-lsp-server's
6868
configuration](https://github.com/python-lsp/python-lsp-server/#configuration). These are
6969
the valid configuration keys:
7070

71-
- `pylsp.plugins.ruff.enabled`: boolean to enable/disable the plugin. `true` by default.
71+
- `pylsp.plugins.ruff.enabled`: Boolean to enable/disable the plugin. `true` by default.
7272
- `pylsp.plugins.ruff.config`: Path to optional `pyproject.toml` file.
7373
- `pylsp.plugins.ruff.exclude`: Exclude files from being checked by `ruff`.
7474
- `pylsp.plugins.ruff.executable`: Path to the `ruff` executable. Uses `os.executable -m "ruff"` by default.
@@ -79,7 +79,8 @@ the valid configuration keys:
7979
- `pylsp.plugins.ruff.select`: List of error codes to enable.
8080
- `pylsp.plugins.ruff.extendSelect`: Same as select, but append to existing error codes.
8181
- `pylsp.plugins.ruff.format`: List of error codes to fix during formatting. Empty by default, use `["I"]` here to get import sorting as part of formatting.
82-
- `pylsp.plugins.ruff.unsafeFixes`: boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
82+
- `pylsp.plugins.ruff.unsafeFixes`: Boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
83+
- `pylsp.plugins.ruff.preview`: Boolean that enables/disables rules & fixes that are marked "preview" by `ruff`. `false` by default.
8384
- `pylsp.plugins.ruff.severities`: Dictionary of custom severity levels for specific codes, see [below](#custom-severities).
8485
- `pylsp.plugins.ruff.targetVersion`: The minimum Python version to target.
8586

pylsp_ruff/plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ def build_check_arguments(
571571
if settings.line_length:
572572
args.append(f"--line-length={settings.line_length}")
573573

574+
if settings.preview:
575+
args.append("--preview")
576+
574577
if settings.unsafe_fixes:
575578
args.append("--unsafe-fixes")
576579

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)