From 5c6a9593216cfbbaf57fc266304183e59b72cbf5 Mon Sep 17 00:00:00 2001 From: Felix Williams Date: Tue, 14 Nov 2023 10:50:30 +0000 Subject: [PATCH] remove option to add `--extension` --- README.md | 1 - pylsp_ruff/plugin.py | 6 +----- pylsp_ruff/settings.py | 2 -- tests/test_ruff_lint.py | 17 +---------------- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 713ca97..71f02ea 100644 --- a/README.md +++ b/README.md @@ -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/). diff --git a/pylsp_ruff/plugin.py b/pylsp_ruff/plugin.py index 94972b4..590ff49 100644 --- a/pylsp_ruff/plugin.py +++ b/pylsp_ruff/plugin.py @@ -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: @@ -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) diff --git a/pylsp_ruff/settings.py b/pylsp_ruff/settings.py index 59fecd0..0ccda7e 100644 --- a/pylsp_ruff/settings.py +++ b/pylsp_ruff/settings.py @@ -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("_") diff --git a/tests/test_ruff_lint.py b/tests/test_ruff_lint.py index b456a5b..c56a1ac 100644 --- a/tests/test_ruff_lint.py +++ b/tests/test_ruff_lint.py @@ -85,7 +85,6 @@ def test_ruff_config_param(workspace): "config": ruff_conf, "extendSelect": ["D", "F"], "extendIgnore": ["E"], - "extension": {"ipynb": "python"}, } } } @@ -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): @@ -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')}", @@ -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