Skip to content

Support setting target-version #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ the valid configuration keys:
- `pylsp.plugins.ruff.format`: List of error codes to fix during formatting. The default is `["I"]`, any additional codes are appended to this list.
- `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 @@ -551,6 +551,9 @@ def build_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