Skip to content

Fix formatting issues reported by the latest Ruff version #616

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 2 commits into from
Feb 6, 2025
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ jobs:
# This error cannot be resolved by adding a pylint: disable=unused-argument comment ...
- run: |
pip install -e .[pylint,pycodestyle]
pip install ruff
pip install ruff==0.9.4
- name: ruff linter and code style checks
run: ruff check pylsp test
- name: ruff code formatter check
2 changes: 1 addition & 1 deletion pylsp/_utils.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
# Eol chars accepted by the LSP protocol
# the ordering affects performance
EOL_CHARS = ["\r\n", "\r", "\n"]
EOL_REGEX = re.compile(f'({"|".join(EOL_CHARS)})')
EOL_REGEX = re.compile(f"({'|'.join(EOL_CHARS)})")

log = logging.getLogger(__name__)

2 changes: 2 additions & 0 deletions test/plugins/test_completion.py
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ class TypeCase(NamedTuple):
expected: lsp.CompletionItemKind


# fmt: off
TYPE_CASES: Dict[str, TypeCase] = {
"variable": TypeCase(
document="test = 1\ntes",
@@ -115,6 +116,7 @@ class TypeCase(NamedTuple):
expected=lsp.CompletionItemKind.Property,
),
}
# fmt: on


@pytest.mark.parametrize("case", list(TYPE_CASES.values()), ids=list(TYPE_CASES.keys()))
4 changes: 2 additions & 2 deletions test/test_utils.py
Original file line number Diff line number Diff line change
@@ -45,14 +45,14 @@ def notebook_with_python_cells(cells: List[str]):
"cells": [
{
"kind": NotebookCellKind.Code,
"document": f"cell_{i+1}_uri",
"document": f"cell_{i + 1}_uri",
}
for i in range(len(cells))
],
},
"cellTextDocuments": [
{
"uri": f"cell_{i+1}_uri",
"uri": f"cell_{i + 1}_uri",
"languageId": "python",
"text": cell,
}
10 changes: 5 additions & 5 deletions test/test_workspace.py
Original file line number Diff line number Diff line change
@@ -238,7 +238,7 @@ def test_workspace_loads_pycodestyle_config(pylsp, tmpdir) -> None:
# Test that project settings are loaded
workspace2_dir = tmpdir.mkdir("NewTest456")
cfg = workspace2_dir.join("pycodestyle.cfg")
cfg.write("[pycodestyle]\n" "max-line-length = 1000")
cfg.write("[pycodestyle]\nmax-line-length = 1000")

workspace1 = {"uri": str(workspace1_dir)}
workspace2 = {"uri": str(workspace2_dir)}
@@ -257,7 +257,7 @@ def test_workspace_loads_pycodestyle_config(pylsp, tmpdir) -> None:
# Test switching to another workspace with different settings
workspace3_dir = tmpdir.mkdir("NewTest789")
cfg1 = workspace3_dir.join("pycodestyle.cfg")
cfg1.write("[pycodestyle]\n" "max-line-length = 20")
cfg1.write("[pycodestyle]\nmax-line-length = 20")

workspace3 = {"uri": str(workspace3_dir)}

@@ -310,9 +310,9 @@ def test_progress_simple(workspace, consumer) -> None:
assert init_call[0][0]["method"] == "window/workDoneProgress/create"

# same method for all calls
assert all(
call[0][0]["method"] == "$/progress" for call in progress_calls
), consumer.call_args_list
assert all(call[0][0]["method"] == "$/progress" for call in progress_calls), (
consumer.call_args_list
)

# same token used in all calls
assert (