Skip to content

Commit

Permalink
Add setting for enabling/disabling Preview rules (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
magnuslarsen authored Nov 25, 2023
1 parent e5091cb commit 5d7338d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The plugin follows [python-lsp-server's
configuration](https://github.com/python-lsp/python-lsp-server/#configuration). These are
the valid configuration keys:

- `pylsp.plugins.ruff.enabled`: boolean to enable/disable the plugin. `true` by default.
- `pylsp.plugins.ruff.enabled`: Boolean to enable/disable the plugin. `true` by default.
- `pylsp.plugins.ruff.config`: Path to optional `pyproject.toml` file.
- `pylsp.plugins.ruff.exclude`: Exclude files from being checked by `ruff`.
- `pylsp.plugins.ruff.executable`: Path to the `ruff` executable. Uses `os.executable -m "ruff"` by default.
Expand All @@ -79,7 +79,8 @@ the valid configuration keys:
- `pylsp.plugins.ruff.select`: List of error codes to enable.
- `pylsp.plugins.ruff.extendSelect`: Same as select, but append to existing error codes.
- `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.
- `pylsp.plugins.ruff.unsafeFixes`: boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
- `pylsp.plugins.ruff.unsafeFixes`: Boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
- `pylsp.plugins.ruff.preview`: Boolean that enables/disables rules & fixes that are marked "preview" by `ruff`. `false` by default.
- `pylsp.plugins.ruff.severities`: Dictionary of custom severity levels for specific codes, see [below](#custom-severities).
- `pylsp.plugins.ruff.targetVersion`: The minimum Python version to target.

Expand Down
3 changes: 3 additions & 0 deletions pylsp_ruff/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,9 @@ def build_check_arguments(
if settings.line_length:
args.append(f"--line-length={settings.line_length}")

if settings.preview:
args.append("--preview")

if settings.unsafe_fixes:
args.append("--unsafe-fixes")

Expand Down
1 change: 1 addition & 0 deletions pylsp_ruff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PluginSettings:

format: Optional[List[str]] = None

preview: bool = False
unsafe_fixes: bool = False

severities: Optional[Dict[str, str]] = None
Expand Down

0 comments on commit 5d7338d

Please sign in to comment.