Skip to content

Commit

Permalink
Support setting target-version (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
jspricke authored Nov 25, 2023
1 parent 42095ef commit e5091cb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ the valid configuration keys:
- `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.severities`: Dictionary of custom severity levels for specific codes, see [below](#custom-severities).
- `pylsp.plugins.ruff.targetVersion`: The minimum Python version to target.

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

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

if settings.target_version:
args.append(f"--target-version={settings.target_version}")

if settings.per_file_ignores:
for path, errors in settings.per_file_ignores.items():
if not PurePath(document_path).match(path):
Expand Down
2 changes: 2 additions & 0 deletions pylsp_ruff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class PluginSettings:

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

target_version: Optional[str] = None


def to_camel_case(snake_str: str) -> str:
components = snake_str.split("_")
Expand Down

0 comments on commit e5091cb

Please sign in to comment.