Skip to content

Commit

Permalink
remove option to add --extension
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-cw committed Nov 14, 2023
1 parent 8bf9880 commit 5c6a959
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ 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.extension`: Dictionary of file extensions to file type e.g. `{"ipynb":"python"}`. Used to override ruff's own inference.

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

Expand Down
6 changes: 1 addition & 5 deletions pylsp_ruff/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def build_arguments(
args.append("--exit-zero")
# Use the json formatting for easier evaluation
args.append("--output-format=json")
args.append("--extension=ipynb:python")
if fix:
args.append("--fix")
else:
Expand Down Expand Up @@ -556,11 +557,6 @@ def build_arguments(
if not PurePath(document_path).match(path):
continue
args.append(f"--ignore={','.join(errors)}")
if settings.extension:
extension_pairs = ",".join(
f"{ext}:{lang}" for ext, lang in settings.extension.items()
)
args.append(f"--extension={extension_pairs}")

if extra_arguments:
args.extend(extra_arguments)
Expand Down
2 changes: 0 additions & 2 deletions pylsp_ruff/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class PluginSettings:

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

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


def to_camel_case(snake_str: str) -> str:
components = snake_str.split("_")
Expand Down
17 changes: 1 addition & 16 deletions tests/test_ruff_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def test_ruff_config_param(workspace):
"config": ruff_conf,
"extendSelect": ["D", "F"],
"extendIgnore": ["E"],
"extension": {"ipynb": "python"},
}
}
}
Expand All @@ -97,7 +96,6 @@ def test_ruff_config_param(workspace):
assert f"--config={ruff_conf}" in call_args
assert "--extend-select=D,F" in call_args
assert "--extend-ignore=E" in call_args
assert "--extension=ipynb:python" in call_args


def test_ruff_executable_param(workspace):
Expand Down Expand Up @@ -183,6 +181,7 @@ def f():
"--quiet",
"--exit-zero",
"--output-format=json",
"--extension=ipynb:python",
"--no-fix",
"--force-exclude",
f"--stdin-filename={os.path.join(workspace.root_path, '__init__.py')}",
Expand Down Expand Up @@ -258,20 +257,6 @@ def f():
workspace.put_document(doc_uri, doc_str)
doc = workspace.get_document(doc_uri)

diags = ruff_lint.pylsp_lint(workspace, doc)
# without the extension option, we get a syntax error because ruff expects JSON
assert len(diags)
assert diags[0]["code"] == "E999"

workspace._config.update(
{
"plugins": {
"ruff": {
"extension": {"ipynb": "python"},
}
}
}
)
diags = ruff_lint.pylsp_lint(workspace, doc)
diag_codes = [diag["code"] for diag in diags]
assert "E999" not in diag_codes
Expand Down

0 comments on commit 5c6a959

Please sign in to comment.