From 791791f96d96c550564dd11d86a490574e650c40 Mon Sep 17 00:00:00 2001 From: Bzero Date: Mon, 6 Oct 2025 09:23:28 +0200 Subject: [PATCH] Adapt to ruff version 0.13. --- tests/test_globalstate.py | 2 +- typstwriter/compiler_tools.py | 2 +- typstwriter/editor.py | 6 +++--- typstwriter/fs_explorer.py | 2 +- typstwriter/util.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_globalstate.py b/tests/test_globalstate.py index 5d79859..1b7f761 100644 --- a/tests/test_globalstate.py +++ b/tests/test_globalstate.py @@ -21,7 +21,7 @@ def test_Signal_emitted(self, qtbot): def test_AttributeError(self, qtbot): """Make sure other fields trigger AttributeError.""" state = globalstate.SingleState("") - with pytest.raises(AttributeError, match="The only valid attributes are 'Value' and 'Signal'."): + with pytest.raises(AttributeError, match=r"The only valid attributes are 'Value' and 'Signal'."): state.Test = "Test" diff --git a/typstwriter/compiler_tools.py b/typstwriter/compiler_tools.py index 1258696..81f1035 100644 --- a/typstwriter/compiler_tools.py +++ b/typstwriter/compiler_tools.py @@ -77,7 +77,7 @@ def main_path_edited(self): def open_file_dialog(self): """Open a dialog to select the main file.""" filters = "Typst Files (*.typ);;Any File (*)" - path, cd = QtWidgets.QFileDialog.getOpenFileName(self, "Open File", state.working_directory.Value, filters) + path, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Open File", state.working_directory.Value, filters) if os.path.isfile(path): self.line_edit_main.setText(path) diff --git a/typstwriter/editor.py b/typstwriter/editor.py index 42bf3f4..e760ad1 100644 --- a/typstwriter/editor.py +++ b/typstwriter/editor.py @@ -101,7 +101,7 @@ def open_file(self, path): def open_file_dialog(self): """Open a dialog to open an existing file.""" filters = "Typst Files (*.typ);;Bibliography Files (*.bib *.yml);;Any File (*)" - path, cd = QtWidgets.QFileDialog.getOpenFileName(self, "Open File", state.working_directory.Value, filters) + path, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Open File", state.working_directory.Value, filters) if path: self.open_file(path) @@ -448,7 +448,7 @@ def save(self): def save_as(self): """Save file under a new name.""" - path, cd = QtWidgets.QFileDialog.getSaveFileName(self, "Save File", state.working_directory.Value) + path, _ = QtWidgets.QFileDialog.getSaveFileName(self, "Save File", state.working_directory.Value) if os.path.exists(path) or os.access(os.path.dirname(path), os.W_OK): self.path = path @@ -893,7 +893,7 @@ def highlight_errors(self, errors): """Highlight compiler errors.""" highlights = [] for e in errors: - (error, line, col, length) = e + (_, line, col, length) = e # the error code is not currently used but it may be displayed in the editor in the future cursor = QtGui.QTextCursor(self.document()) diff --git a/typstwriter/fs_explorer.py b/typstwriter/fs_explorer.py index 5509ccb..992ece8 100644 --- a/typstwriter/fs_explorer.py +++ b/typstwriter/fs_explorer.py @@ -395,7 +395,7 @@ def paste_from_clipboard(self, path): for uri in mime_data.data("text/uri-list").data().decode().split(): fs = QtCore.QUrl(uri).toLocalFile() if os.path.exists(fs): - head, tail = os.path.split(fs) + _, tail = os.path.split(fs) path_to = os.path.join(path, tail) if os.path.exists(path_to): diff --git a/typstwriter/util.py b/typstwriter/util.py index bf1b672..b2bd199 100644 --- a/typstwriter/util.py +++ b/typstwriter/util.py @@ -137,7 +137,7 @@ def open_with_external_program(path): def pdf_path(typst_path): """Convert a input path to a pdf output path.""" - (trunk, ext) = os.path.splitext(typst_path) + (trunk, _) = os.path.splitext(typst_path) pdf_path = trunk + ".pdf" return pdf_path