Skip to content
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

Support ruff 0.1.0 #48

Closed
Closed
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
6 changes: 5 additions & 1 deletion pylsp_ruff/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def build_arguments(
# Suppress update announcements
args.append("--quiet")
# Use the json formatting for easier evaluation
args.append("--format=json")
args.append("--output-format=json")
if fix:
args.append("--fix")
else:
Expand All @@ -510,6 +510,9 @@ def build_arguments(
if settings.line_length:
args.append(f"--line-length={settings.line_length}")

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

if settings.exclude:
args.append(f"--exclude={','.join(settings.exclude)}")

Expand Down Expand Up @@ -583,6 +586,7 @@ def load_settings(workspace: Workspace, document_path: str) -> PluginSettings:
return PluginSettings(
enabled=plugin_settings.enabled,
executable=plugin_settings.executable,
unsafe_fixes=plugin_settings.unsafe_fixes,
extend_ignore=plugin_settings.extend_ignore,
extend_select=plugin_settings.extend_select,
format=plugin_settings.format,
Expand Down
1 change: 1 addition & 0 deletions pylsp_ruff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class PluginSettings:
enabled: bool = True
executable: str = "ruff"
unsafe_fixes: bool = False

config: Optional[str] = None
line_length: Optional[int] = None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
requires-python = ">=3.7"
license = {text = "MIT"}
dependencies = [
"ruff>=0.0.267,<0.1.0",
"ruff>=0.1.0, <0.2.0",
"python-lsp-server",
"lsprotocol>=2022.0.0a1",
"tomli>=1.1.0; python_version < '3.11'",
Expand Down
9 changes: 9 additions & 0 deletions tests/test_code_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ def f():
pass
"""
)
workspace._config.update(
{
"plugins": {
"ruff": {
"unsafeFixes": True,
}
}
}
)
_, doc = temp_document(codeaction_str, workspace)
settings = ruff_lint.load_settings(workspace, doc.path)
fixed_str = ruff_lint.run_ruff_fix(doc, settings)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ruff_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def f():
assert call_args == [
"ruff",
"--quiet",
"--format=json",
"--output-format=json",
"--no-fix",
"--force-exclude",
f"--stdin-filename={os.path.join(workspace.root_path, '__init__.py')}",
Expand Down
Loading