Skip to content

Commit e5091cb

Browse files
authored
Support setting target-version (#60)
1 parent 42095ef commit e5091cb

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ the valid configuration keys:
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.
8282
- `pylsp.plugins.ruff.unsafeFixes`: boolean that enables/disables fixes that are marked "unsafe" by `ruff`. `false` by default.
8383
- `pylsp.plugins.ruff.severities`: Dictionary of custom severity levels for specific codes, see [below](#custom-severities).
84+
- `pylsp.plugins.ruff.targetVersion`: The minimum Python version to target.
8485

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

pylsp_ruff/plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,9 @@ def build_check_arguments(
589589
if settings.extend_ignore:
590590
args.append(f"--extend-ignore={','.join(settings.extend_ignore)}")
591591

592+
if settings.target_version:
593+
args.append(f"--target-version={settings.target_version}")
594+
592595
if settings.per_file_ignores:
593596
for path, errors in settings.per_file_ignores.items():
594597
if not PurePath(document_path).match(path):

pylsp_ruff/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class PluginSettings:
2727

2828
severities: Optional[Dict[str, str]] = None
2929

30+
target_version: Optional[str] = None
31+
3032

3133
def to_camel_case(snake_str: str) -> str:
3234
components = snake_str.split("_")

0 commit comments

Comments
 (0)