diff --git a/README.md b/README.md index 80cd40a..288bb40 100644 --- a/README.md +++ b/README.md @@ -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/). diff --git a/pylsp_ruff/plugin.py b/pylsp_ruff/plugin.py index a70298e..04782c5 100644 --- a/pylsp_ruff/plugin.py +++ b/pylsp_ruff/plugin.py @@ -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): diff --git a/pylsp_ruff/settings.py b/pylsp_ruff/settings.py index 0ccda7e..b5bc24d 100644 --- a/pylsp_ruff/settings.py +++ b/pylsp_ruff/settings.py @@ -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("_")